Brief Java Early Objects 9th Edition Cay Horstmann download pdf
Brief Java Early Objects 9th Edition Cay Horstmann download pdf
https://ebookultra.com/download/java-concepts-5th-edition-cay-s-
horstmann/
https://ebookultra.com/download/java-concepts-5-pap-onl-edition-cay-
horstmann/
https://ebookultra.com/download/big-java-compatible-with-
java-5-6-and-7-4th-edition-cay-s-horstmann/
https://ebookultra.com/download/python-for-everyone-2nd-edition-cay-
horstmann-rance-necaise/
Java How to Program Early Objects 10th ed Edition Deitel
https://ebookultra.com/download/java-how-to-program-early-
objects-10th-ed-edition-deitel/
https://ebookultra.com/download/starting-out-with-java-early-
objects-5th-edition-tony-gaddis/
https://ebookultra.com/download/starting-out-with-c-early-objects-9th-
global-edition-edition-gaddis/
https://ebookultra.com/download/starting-out-with-java-early-
objects-5-e-5th-edition-tony-gaddis/
https://ebookultra.com/download/core-java-volume-1-fundamentals-8th-
ed-edition-horstmann/
Brief Java Early Objects 9th Edition Cay Horstmann
Digital Instant Download
Author(s): Cay Horstmann
ISBN(s): 9781119499138, 1119499135
Edition: 9
File Details: PDF, 31.67 MB
Year: 2019
Language: english
9/e
Cay Horstmann
Brief Java
Early Objects
9/e
Brief Java
Early Objects
Cay Horstmann
San Jose State University
This book was set in 10.5/12 Stempel Garamond LT Std by Publishing Services, and printed and bound by Quad
Graphics/Versailles. The cover was printed by Quad Graphics/Versailles.
Founded in 1807, John Wiley & Sons, Inc. has been a valued source of knowledge and understanding for more
than 200 years, helping people around the world meet their needs and fulfill their aspirations. Our company is
built on a foundation of principles that include responsibility to the communities we serve and where we live
and work. In 2008, we launched a Corporate Citizenship Initiative, a global effort to address the environmental,
social, economic, and ethical challenges we face in our business. Among the issues we are addressing are carbon
impact, paper specifications and procurement, ethical conduct within our business and among our vendors,
and community and charitable support. For more information, please visit our website: www.wiley.com/go/
citizenship.
Copyright © 2019, 2016 John Wiley & Sons, Inc. All rights reserved. No part of this publication may be repro-
duced, stored in a retrieval system, or transmitted in any form or by any means, electronic, mechanical, photo-
copying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United
States Copyright Act, without either the prior written permission of the Publisher, or authorization through
payment of the appropriate per-copy fee to the Copyright Clearance Center, Inc., 222 Rosewood Drive, Dan-
vers, MA 01923, (978) 750-8400, fax (978) 646-8600, or on the Web at www.copyright.com. Requests to the
Publisher for permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 111
River Street, Hoboken, NJ 07030-5774, (201) 748-6011, fax (201) 748-6008.
Evaluation copies are provided to qualified academics and professionals for review purposes only, for use in
their courses during the next academic year. These copies are licensed and may not be sold or transferred to a
third party. Upon completion of the review period, please return the evaluation copy to Wiley. Return instruc-
tions and a free of charge return shipping label are available at: www.wiley.com/go/returnlabel. If you have
chosen to adopt this textbook for use in your course, please accept this book as your complimentary desk copy.
Outside of the United States, please contact your local representative.
The inside back cover will contain printing identification and country of origin if omitted from this page. In
addition, if the ISBN on the back cover differs from the ISBN on this page, the one on the back cover is correct.
10 9 8 7 6 5 4 3 2 1
P R E FA C E
This book is an introduction to Java and computer programming that focuses on the
essentials—and on effective learning. The book is designed to serve a wide range of
student interests and abilities and is suitable for a first course in programming for
computer scientists, engineers, and students in other disciplines. No prior program-
ming experience is required, and only a modest amount of high school algebra is
needed.
Here are the key features of this book:
Start objects early, teach object orientation gradually.
In Chapter 2, students learn how to use objects and classes from the standard library.
Chapter 3 shows the mechanics of implementing classes from a given specification.
Students then use simple objects as they master branches, loops, and arrays. Object-
oriented design starts in Chapter 8. This gradual approach allows students to use
objects throughout their study of the core algorithmic topics, without teaching bad
habits that must be un-learned later.
Guidance and worked examples help students succeed.
Beginning programmers often ask “How do I start? Now what do I do?” Of course,
an activity as complex as programming cannot be reduced to cookbook-style instruc-
tions. However, step-by-step guidance is immensely helpful for building confidence
and providing an outline for the task at hand. “How To” guides help students with
common programming tasks. Numerous Worked Examples demonstrate how to
apply chapter concepts to interesting problems.
Problem solving strategies are made explicit.
Practical, step-by-step illustrations of techniques help students devise and evaluate
solutions to programming problems. Introduced where they are most relevant, these
strategies address barriers to success for many students. Strategies included are:
• Algorithm Design (with pseudocode) • Solve a Simpler Problem First
• Tracing Objects • Adapting Algorithms
• First Do It By Hand (doing sample • Discovering Algorithms by
calculations by hand) Manipulating Physical Objects
• Flowcharts • Patterns for Object Data
• Selecting Test Cases • Thinking Recursively
• Hand-Tracing • Estimating the Running Time of
• Storyboards an Algorithm
Interactive Learning
With this edition, interactive content is front and center. Immersive activities integrate
with this text and engage students in activities designed to foster in-depth learning.
Students don’t just watch animations and code traces, they work on generating
them. Live code samples invite the reader to experiment and to learn programming
constructs first hand. The activities provide instant feedback to show students what
they did right and where they need to study more.
1. Introduction
Fundamentals
2. Using Objects
Object-Oriented Design
Data Structures & Algorithms
e eText Chapters
3. Implementing
Classes
4. Fundamental
Data Types
5. Decisions
6. Loops
e
Framework
10. Interfaces
Figure 1
Chapter 12. Object-
Oriented Design
Dependencies
you will build your own simple classes from given specifications. Fundamental data
types, branches, loops, and arrays are covered in Chapters 4–7.
Appendices
Many instructors find it highly beneficial to require a consistent style for all assign-
ments. If the style guide in Appendix E conflicts with instructor sentiment or local
customs, however, it is available in electronic form so that it can be modified. Appen-
dices F–J are available in the eText.
A. The Basic Latin and Latin-1 Subsets of Unicode
B. Java Operator Summary
C. Java Reserved Word Summary
D. The Java Library
E. Java Language Coding Guidelines
F. Tool Summary
G. Number Systems
H. UML Summary
I. Java Syntax Summary
J. HTML Summary
Customized formats are also available in both print and digital formats and pro-
vide your students with curated content based on your unique syllabus.
Please contact your Wiley sales rep for more information about any of these
options.
Web Resources
This book is complemented by a complete suite of online resources. Go to www.wiley.
com/go/bjeo7 to visit the online companion sites, which include
• Source code for all example programs in the book and its Worked Examples, plus
additional example programs.
• Worked Examples that apply the problem-solving steps in the book to other
realistic examples.
• Lecture presentation slides (for instructors only).
• Solutions to all review and programming exercises (for instructors only).
• A test bank that focuses on skills, not just terminology (for instructors only). This
extensive set of multiple-choice questions can be used with a word processor or
imported into a course management system.
• CodeCheck®, an innovative online service that allows instructors to design their
own automatically graded programming exercises.
In the same way that there can be a street named “Main Street” in different cities,
a Java program can have multiple variables with the same name.
evaluating proposed solutions, often Now how does that help us with our problem, switching the first and the second
using pencil and paper or other half of the array?
Let’s put the first coin into place, by swapping it with the fifth coin. However, as
artifacts. These sections emphasize Java programmers, we will say that we swap the coins in positions 0 and 4:
Step 1 Decide what work must be done inside the loop. Worked Examples apply
Every loop needs to do some kind of repetitive work, such as
• Reading another item. the steps in the How To to a
• Updating a value (such as a bank balance or total).
WORKED EXAMPLE 6.1 different example, showing
• Incrementing a counter.
Credit Card Processing
If you can’t figure out what needs to go inside the loop, start by writing down the steps that how they can be used to
you would take if you
howsolved
to use the problem by hand. Forfrom
example, with the temperature reading
problem, you
Learn
might See
number. write
a loop to remove spaces a credit
your eText or visit wiley.com/go/bjeo7.
card
plan, implement, and test
© MorePixels/iStockphoto. a solution to another
programming problem.
Table 1 Variable Declarations in Java
Variable Name Comment
int width = 20; Declares an integer variable and initializes it with 20.
int perimeter = 4 * width; The initial value need not be a fixed value. (Of course, width
must have been previously declared.)
String greeting = "Hi!"; This variable has the type String and is initialized with the
Example tables support beginners
string “Hi”. with multiple, concrete examples.
height = 30; Error: The type is missing. This statement is not a declaration
but an assignment of a new value to an existing variable—see These tables point out common
Section 2.2.5.
errors and present another quick
int width = "20"; Error: You cannot initialize a number with the string “20”.
(Note the quotation marks.) reference to the section’s topic.
int width; Declares an integer variable without initializing it. This can be a
cause for errors—see Common Error 2.1.
int width, height; Declares two integer variables in a single statement. In this
book, we will declare each variable in a separate statement.
Figure 3
Progressive figures trace code Execution of a
1 Initialize counter
for (int counter = 5; counter <= 10; counter++)
{
for Loop
segments to help students visualize counter = 5 }
sum = sum + counter;
4 Update counter
for (int counter = 5; counter <= 10; counter++)
{
sum = sum + counter;
counter = 6 }
sec01/ElevatorSimulation.java
1 import java.util.Scanner; 5 Check condition again
for (int counter = 5; counter <= 10; counter++)
2 {
3 /** sum = sum + counter;
4 This program simulates an elevator panel that skips the 13th floor. counter = 6 }
5 */
6 public class ElevatorSimulation
7 {
8 public static void main(String[] args)
9 { The for loop neatly groups the initialization, condition, and update expressions
10 Scanner in = new Scanner(System.in); together. However, it is important to realize that these expressions are not executed
11 System.out.print("Floor: ");
together (see Figure 3).
12 int floor = in.nextInt();
13
• The initialization is executed once, before the loop is entered. 1
14 // Adjust floor if necessary
15 • The condition is checked before each iteration. 2 5
16 int actualFloor;
17 if (floor > 13) • The update is executed after each iteration. 4
Optional science and business • Science P6.15 Radioactive decay of radioactive materials can be
modeled by the equation A = A0e-t (log 2/h), where A is
exercises engage students with the amount of the material at time t, A0 is the amount
realistic applications of Java. at time 0, and h is the half-life.
Technetium-99 is a radioisotope that is used in imaging
of the brain. It has a half-life of 6 hours. Your program
should display the relative amount A / A0 in a patient
body every hour for 24 hours after receiving a dose.
Array a.length
String a.length()
more productive with tips and the program run above. When the TaxReturn object is constructed,
the income instance variable is set to 80,000 and status is set to
Hand-tracing helps you
understand whether a
techniques such as hand-tracing. MARRIED. Then the getTax method is called. In lines 31 and 32 of Tax-
Return.java, tax1 and tax2 are initialized to 0.
program works correctly.
Special Topics present optional In a program with a graphical user interface, you will want to use a file dialog box (such as the
one shown in the figure below) whenever the users of your program need to pick a file. The
topics and provide additional JFileChooser class implements a file dialog box for the Swing user-interface toolkit.
The JFileChooser class has many options to fine-tune the display of the dialog box, but in its
explanation of others. most basic form it is quite simple: Construct a file chooser object; then call the showOpenDialog
or showSaveDialog method. Both methods show the same dialog box, but the button for select-
ing a file is labeled “Open” or “Save”, depending on which method you call.
For better placement of the dialog box on the screen, you can specify the user-interface
component over which to pop up the dialog box. If you don’t care where the dialog box pops
up, you can simply pass null. The showOpenDialog and showSaveDialog methods return either
JFileChooser.APPROVE_OPTION, if the user has chosen a file, or JFileChooser.CANCEL_OPTION, if the
user canceled the selection. If a file was chosen, then you call the getSelectedFile method to
obtain a File object that describes the file.
Here is a complete example:
JFileChooser chooser = new JFileChooser();
Scanner in = null;
if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION)
{
complete programs for students EXAMPLE CODE See special_topic_2 of your eText or companion code for a program that demonstrates how to use a file
chooser.
Acknowledgments
Many thanks to Joanna Dingle, Crystal Franks, Graig Donini, and Michael Mac-
Dougald at John Wiley & Sons, and Vickie Piercey at Publishing Services for their
help with this project. An especially deep acknowledgment and thanks goes to Cindy
Johnson for her hard work, sound judgment, and amazing attention to detail.
Special thanks to Stephen Gilbert, Orange Coast College, for his excellent help
with the interactive exercises.
Many thanks to the individuals who worked through the many new activities in
this edition, reviewed the manuscript, made valuable suggestions, and brought errors
and omissions to my attention. They include:
Radhouane Chouchane, Columbus State University
Sussan Einakian, California Polytechnic State University
Jon Hanrath, Illinois Institute of Technology
Brian King, Bucknell University
Kathleen O’Brien, San Jose State University
Eman Saleh, University of Georgia
William Wei, New York Institute of Technology
Each new edition builds on the suggestions and experiences of prior reviewers, con-
tributors, and users. I am grateful for the invaluable contributions these individuals
have made:
Eric Aaron, Wesleyan University Jerry Cain, Stanford University
James Agnew, Anne Arundel Adam Cannon, Columbia University
Community College Michael Carney, Finger Lakes
Tim Andersen, Boise State University Community College
Ivan Bajic, San Diego State University Robin Carr, Drexel University
Greg Ballinger, Miami Dade College Christopher Cassa, Massachusetts
Ted Bangay, Sheridan Institute Institute of Technology
of Technology Nancy Chase, Gonzaga University
Ian Barland, Radford University Dr. Suchindran S. Chatterjee, Arizona
George Basham, Franklin University State University
Jon Beck, Truman State University Archana Chidanandan, Rose-Hulman
Sambit Bhattacharya, Fayetteville Institute of Technology
State University Vincent Cicirello, The Richard Stockton
Rick Birney, Arizona State University College of New Jersey
Paul Bladek, Edmonds Community Gerald Cohen, The Richard Stockton
College College of New Jersey
Matt Boutell, Rose-Hulman Institute of Teresa Cole, Boise State University
Technology Deborah Coleman, Rochester Institute
Joseph Bowbeer, Vizrea Corporation of Technology
Timothy A. Budd, Oregon State Tina Comston, Franklin University
University Lennie Cooper, Miami Dade College
John Bundy, DeVry University Chicago Jose Cordova, University of Louisiana,
Robert P. Burton, Brigham Young Monroe
University Valentino Crespi, California State
Frank Butt, IBM University, Los Angeles
xix
9.2 Implementing Subclasses 310 10.8 Building Applications with Buttons 368
Overriding the toString Method 330 11.2 Text Input and Output 389
The equals Method 332 Reading Words 389
The instanceof Operator 333 Reading Characters 390
ST6 Inheritance and the toString Method 335 Classifying Characters 390
ST7 Inheritance and the equals Method 336 Reading Lines 390
Scanning a String 392
Converting Strings to Numbers 392
10 INTERFACES 339
Avoiding Errors When Reading Numbers 392
10.1 Using Interfaces for Algorithm Mixing Number, Word, and Line Input 393
Formatting Output 394
Reuse 340
ST4 Regular Expressions 395
Discovering an Interface Type 340
ST5 Reading an Entire File 396
Declaring an Interface Type 341
Implementing an Interface Type 343 11.3 Command Line Arguments 396
Comparing Interfaces and Inheritance 345 HT1 Processing Text Files 399
ST1 Constants in Interfaces 346 WE1 Analyzing Baby Names 403
ST2 Nonabstract Interface Methods 347 11.4 Exception Handling 403
10.2 Working with Interface Variables 348 Throwing Exceptions 403
Converting from Classes to Interfaces 348 Catching Exceptions 405
Invoking Methods on Interface Variables 349 Checked Exceptions 407
Casting from Interfaces to Classes 349 Closing Resources 409
WE1 Investigating Number Sequences 350 Designing Your Own Exception Types 410
15.4 Maps 525 APPENDIX A THE BASIC LATIN AND LATIN-1 SUBSETS
ST1 Updating Map Entries 527 OF UNICODE A-1
HT1 Choosing a Collection 527 APPENDIX B JAVA OPERATOR SUMMARY A-5
WE1 Word Frequency 528 APPENDIX C JAVA RESERVED WORD SUMMARY A-7
ST2 Hash Functions 529 APPENDIX D THE JAVA LIBRARY A-9
15.5 Stacks, Queues, and Priority Queues 531 APPENDIX E JAVA LANGUAGE CODING
Stacks 531
GUIDELINES A-29
Queues 532 APPENDIX F TOOL SUMMARY (ETEXT ONLY)
Priority Queues 533 APPENDIX G NUMBER SYSTEMS (ETEXT ONLY)
15.6 Stack and Queue Applications 534 APPENDIX H UML SUMMARY (ETEXT ONLY)
How Tos
CH AP TE R Common and
Errors Worked Examples
© Steve Simzer/iStockphoto.
1 Introduction ©Omitting
John Bell/iStockphoto.
Semicolons 13 Describing an Algorithm
Misspelling Words 14 with Pseudocode 18
Writing an Algorithm for
Tiling a Floor 20
6 Loops Don’t Think “Are We There Yet?” 177 Writing a Loop 203
Infinite Loops 177 Credit Card Processing 206
Off-by-One Errors 178 Manipulating the Pixels
in an Image 209
Debugging 215
A Sample Debugging Session 217
Do Not Use Magic Numbers 106 Big Numbers 106 Bugs in Silicon 114
Spaces in Expressions 112 Avoiding Negative International Alphabets
Reading Exception Reports 127 Remainders 112 and Unicode 128
Combining Assignment
and Arithmetic 113
Instance Methods and
Static Methods 113
Using Dialog Boxes for Input
and Output 128
Use for Loops for Their Variables Declared in a Digital Piracy 182
Intended Purpose Only 188 for Loop Header 189 The First Bug 217
Choose Loop Bounds That Redirection of Input and Output 194
Match Your Task 188 The Loop-and-a-Half Problem 194
Count Iterations 189 The break and continue
Flowcharts for Loops 191 Statements 195
How Tos
CH AP TE R Common and
Errors
Worked Examples
© Steve Simzer/iStockphoto.
11 Input/Output and Backslashes in File Names 386 Processing Text Files 399
Constructing a Scanner Analyzing Baby Names 403
Exception Handling with a String 386
Use a Single Class for Variation Calling the Superclass Who Controls the Internet? 337
in Values, Inheritance for Constructor 318
Variation in Behavior 309 Dynamic Method Lookup and
the Implicit Parameter 322
Abstract Classes 323
Final Methods and Classes 324
Protected Access 324
Inheritance and the
toString Method 335
Inheritance and the
equals Method 336
Comparing Integers and Floating- Constants in Interfaces 346 Open Source and
Point Numbers 351 Nonabstract Interface Methods 347 Free Software 379
The clone Method and the
Cloneable Interface 352
Lambda Expressions 358
Generic Interface Types 360
Keyboard Events 377
Event Adapters 378
Throw Early, Catch Late 411 Reading Web Pages 387 Encryption Algorithms 402
Do Not Squelch Exceptions 411 File Dialog Boxes 387 The Ariane Rocket Incident 417
Do Throw Specific Character Encodings 388
Exceptions 411 Regular Expressions 395
Reading an Entire File 396
Assertions 411
The try/finally Statement 412
How Tos
CH AP TE R Common and
Errors
Worked Examples
© Steve Simzer/iStockphoto.
14 Sorting and Searching* The compareTo Method Can Enhancing the Insertion
Return Any Integer, Sort Algorithm 507
(eTEXT ONLY) Not Just –1, 0, and 1 506
CHAPTER GOALS
CHAPTER CONTENTS
© JanPietruszka/iStockphoto.
precisely and quickly carry out a task that would take you hours of drudgery, to
make small changes in a program that lead to immediate improvements, and to see the
computer become an extension of your mental powers.
material. A solid-state drive uses electronic components that can retain information
without power, and without moving parts.
To interact with a human user, a computer requires peripheral devices. The com-
puter transmits information (called output) to the user through a display screen,
speakers, and printers. The user can enter information (called input) for the computer
by using a keyboard or a pointing device such as a mouse.
Some computers are self-contained units, whereas others are interconnected
through networks. Through the network cabling, the computer can read data and
programs from central storage locations or send data to other computers. To the user
of a networked computer, it may not even be obvious which data reside on the com-
puter itself and which are transmitted through the network.
Figure 3 gives a schematic overview of the architecture of a personal computer.
Program instructions and data (such as text, numbers, audio, or video) reside in sec-
ondary storage or elsewhere on the network. When a program is started, its instruc-
tions are brought into memory, where the CPU can read them. The CPU reads and
executes one instruction at a time. As directed by these instructions, the CPU reads
data, modifies it, and writes it back to memory or secondary storage. Some program
instructions will cause the CPU to place dots on the display screen or printer or to
vibrate the speaker. As these actions happen many times over and at great speed, the
human user will perceive images and sound. Some program instructions read user
input from the keyboard, mouse, touch sensor, or microphone. The program ana-
lyzes the nature of these inputs and then executes the next appropriate instruction.
Printer
Mouse/Trackpad Disk
Ports controller
Secondary storage
Keyboard
CPU
Monitor
Microphone
Memory
Speakers
Video camera
Network
controller Internet
language, you specify the actions that your program should carry out. A compiler
translates the high-level instructions into the more detailed instructions (called
machine code) required by the CPU. Many different programming languages have
been designed for different purposes.
In 1991, a group led by James Gosling and Patrick
Naughton at Sun Microsystems designed a program-
ming language, code-named “Green”, for use in con-
sumer devices, such as intelligent television “set-top”
boxes. The language was designed to be simple, secure,
and usable for many different processor types. No cus-
tomer was ever found for this technology.
Java was originally
Gosling recounts that in 1994 the team realized,
designed for “We could write a really cool browser. It was one of the
programming few things in the client/server mainstream that needed
consumer devices,
but it was first
some of the weird things we’d done: architecture neu- © James Sullivan/Getty Images.
successfully used tral, real-time, reliable, secure.” Java was introduced to
to write Internet an enthusiastic crowd at the SunWorld exhibition in James Gosling
applets.
1995, together with a browser that ran applets—Java
code that can be located anywhere on the Internet.
The figure at right shows a typical example of an
applet.
Since then, Java has grown at a phenomenal rate.
Programmers have embraced the language because
it is easier to use than its closest rival, C++. In addi-
tion, Java has a rich library that makes it possible
to write portable programs that can bypass pro-
prietary operating systems—a feature that was
eagerly sought by those who wanted to be inde-
pendent of those proprietary systems and was bit-
terly fought by their vendors. A “micro edition” An Applet for Visualizing Molecules
and an “enterprise edition” of the Java library
allow Java programmers to target hardware ranging from smart cards to the largest
Internet servers.
1.2 1998 Swing, Collections framework 7 2011 Small language changes and library
improvements
5 2004 Generic classes, enhanced for 10, 11 2018 Versions with incremental
loop, auto-boxing, improvements are released
enumerations, annotations every six months
Figure 4
Running the
HelloPrinter
Program in an
Integrated Click to compile and run
Development Java program
Environment
Program output
An editor is a
On other computers you first launch an editor, a program that functions like a word
program for entering processor, in which you can enter your Java instructions; you then open a console
and modifying window and type commands to execute your program. You need to find out how to
text, such as a Java
program.
get started with your environment.
Step 2 Write a simple program.
The traditional choice for the very first program in a new programming language is
a program that displays a simple greeting: “Hello, World!”. Let us follow that tradi-
tion. Here is the “Hello, World!” program in Java:
public class HelloPrinter
{
public static void main(String[] args)
{
System.out.println("Hello, World!");
}
}
will appear somewhere on the screen (see Figure 4 and Figure 5).
The Java compiler
In order to run your program, the Java compiler translates your source files (that
translates source is, the statements that you wrote) into class files. (A class file contains instructions for
code into class the Java virtual machine.) After the compiler has translated your source code into
files that contain
instructions for the
virtual machine instructions, the virtual machine executes them. During execution,
Java virtual machine. the virtual machine accesses a library of pre-written code, including the implementa-
tions of the System and PrintStream classes that are necessary for displaying the
program’s output. Figure 6 summarizes the process of creating and running a Java
program. In some programming environments, the compiler and virtual machine are
essentially invisible to the programmer—they are automatically executed whenever
you ask to run a Java program. In other environments, you need to launch the com-
piler and virtual machine explicitly.
Step 4 Organize your work.
As a programmer, you write programs, try them out, and improve them. You store
your programs in files. Files are stored in folders or directories. A folder can contain
Virtual
Editor Compiler
Machine
Class files
Running
Source File Program
Library files
files as well as other folders, which themselves can contain more files and folders (see
Figure 7). This hierarchy can be quite large, and you need not be concerned with all of
its branches. However, you should create folders for organizing your work. It is a
good idea to make a separate folder for your pro-
gramming coursework. Inside that folder, make a
separate folder for each program.
Some programming environments place your
programs into a default location if you don’t spec-
ify a folder yourself. In that case, you need to find
out where those files are located.
Be sure that you understand where your files are
located in the folder hierarchy. This information is
essential when you submit files for grading, and for
making backup copies (see Programming Tip 1.1). Figure 7 A Folder Hierarchy
sec04/HelloPrinter.java
© Amanda Rohde/iStockphoto.
The line
public class HelloPrinter
Each class contains as a part of the “plumbing” that is required to create a Java program. Our first pro-
declarations of gram has all instructions inside the main method of the class.
methods. Each
method contains
The main method contains one or more instructions called statements. Each state-
a sequence ment ends in a semicolon (;). When a program runs, the statements in the main method
of instructions. are executed one by one.
[441] Ks. Socrat. VII 43; Theodorit. V 36. — Mitä tämän retken
lopusta juttelevat, että muka salama tappoi Ruaan ja rutto hänen
väkensä, on perätöntä; sillä Ruas kuoli vasta 434 (ks. Prosp. Tyro,
Chron.).
[449] Ks. Jornandes, de reb. Get. 35: "Bleda enim fratre fraudibus
perempto, qui magna parti regnabat Hunnorum, universum sibi
populum adunavit."
[453] Ks. Prisc. Hist. [Exc. de Legat., ed. Bonn.], sivv. 167, 168.
Muutamat pakolaiset, jotka olivat kuninkaallista sukua, tulivat kohta
ristiin-naulituiksi.
[454] Ks. esim. Priskon historiassa [Exc. de Legat., sivv. 181, 182]
kertomus, kuinka Romalainen hallitus koetti vetää Akazirien eli
Katsarien heimokunnat puolellensa.
[455] Ks. Exc. de Legat., sivv. 141, 169. Ainoastaan Margon pispan
sovinnossa, siv. 140, mainitaan monikossa "οι τών Σκυθών βασιλείς."
[456] Ks. Prisc. Hist. [Exc, de Legat.] sivv. 140, 141, 169. —
Prosp. Aquit. Chron. mainitsee vuodella 442: "Chunis Thracias et
Illyricum saeva populatione vastantibus, exercitus, qui in Sicilia
morabatur, ad defensionem Orientalium provinciarum revertitur."
[460] Ks. Exc. de Legat., ed. Bonn., sivv. 146-150, 169-212, 150,
151. Ranskannettuna löytyy tämä matka-kertomus Guizot'n
teoksessa: Histoire de la civilisation en France, III. Kerrottuna koko
laveudessaan tapaamme samat asiat Amedée Thierry'n kirjassa:
Histoire d'Attila et de ses successeurs, I sivv. 64 seurr.
[463] Ks. Exe. de Legat., ed. Bonn., siv. 151-153; Jornand., de reb.
Get., 42.
[464] Ks. Chron. Paschale, ed. Bonn., siv. 587: "και εδήλωσεν διά
Γότθου ενός πρεσβευτού Ουαλεντινιανώ βασιλεί Ρώμης, Εκέλευσέ
σοι διʹ εμού ό δεσπότης μου και δεσπότης σου Αττίλας, ίνα
ευτρεπίσης αυτό παλάτιν, ομοίως δε και Θεοδοσίω βασιλεί τα αυτά
εν Κωνσταντινουπόλει εδήλωσεν διʹ ενός Γότθου πρεσβευτού" —
Joannis Malalæ; Chronogr., ed. Bonn., siv. 358, kertoo asian melkein
samoilla sanoilla, mutta käsky kuuluu vielä jäykemmältä: "ίνα
ευτρεπίσης αυτώ το παλάτιόν σου."
[466] Ks. Jornand., de reb. Get 36; Exc. de Legat., siv. 152.
[471] Ks. Jornand., de reb. Get. 38: "Reliqua autem, si dici fas est,
turba regum diversarumque nationum ductores, ac si satellites,
nutibus Attilæ attendebant, et ubi oculo annuisset, absque aliqua
murmuratione cum timore et tremore unusquisque astabat, aut
certe, quod jussus fuerat, exsequebatur."
[480] Ks. Prisci Hist. [Exc. de Legat.] siv. 158; Jomand., de reb.
Get. 5.; Nimitön Ravennalainen sanoo: "juxta mare Ponticum patria,
quæ dicitur Onogoria, qaam subtilius Livanius Philosophus vicinam
paludis Mæotidæ summitatis esse decernit."
[481] Ks. Neumann, die Völker des südl. Russl., siv. 92.
[482] Theofanes kutsuu ne Bulgarit, jotka perustivat valtansa
etelä-puolella Tonavaa: "Ονογούνδουροι, Βούλγαροι και Κότραγοι";
ks. Chronogr., siv. 5-15. Konstantino Porfyrogenito sanoo heistä vain:
"πρότερον γαρ Ονογουνδούρους αυτούς εκάλονν".
[486] Ks. Exc. de Eeg., ed. Bonn., sivv. 158, 161. Avarit (Αβάρεις)
asuivat muka valtameren rannalla, josta tavattomat sumut ja suuri
Gripien paljous heidät karkoitti! — Akazirit kirjoitetaan tässä
Ακατίροι, Ακαττίροι.
[487] Näistä retkeistä ks. Am. Thierry, Hist. d'Attila, sivv. 306-393.
[489] Ks. Procop., Bell. Goth. IV 18; Menandri hist. [Exc. de Leg.],
sivv. 344, 345; Agathias V 25.
[490] Ks. K. Pr. Neumann, Die Völker des südl. Russl., 2:te Aufl.,
sivv. 86, 112. — Vertaa ylempänä siv. 141.
[491] Ks, Theophyl. Simoc. VII 7, ed. Bonn., siv. 282: "ό Χαγάνος
ό μέγας δεσπότης επτά γενών και κύριος κλιμάτων της οικουμένης
επτά."
[494] Ks. Theophan. Chronogr., ed. Bonn., siv. 359: "είχον γαρ τας
κόμας όπισθεν μακράς πάνυ δεδεμένας πρανδίοις και πεπλεγμένας, ή
δε λοιπή φορεσία αυτών όμοία των λοιπών Ούννων."
[496] Ks. Pauli. Diac., II 10: "comperta morte Chlotarii regis, Huni,
qui et Avares, super Sigisbertum ejus filium irruunt. Quibus ille in
Thuringia occurrens, eos juxta Albim fluvium potentissime superavit,
eisque petentibus pacem dedit. — Rursum Avares cum Sigisberto in
loco ubi et prius pugnantes, Francorum proterentes exercitum,
Victoriani sunt adepti." Vert. Greg. Turon. hist. IV 23 29; Menandri
hist., ed. Bonn., siv. 302.
[497] Ks. Menandri hist., siv. 299: "αμφί τας είκοσιν χιλιάδας."
[503] Ks. Menandri hist. [Exc. de Legat.], siv. 335: "τον επί του
ουρανού θεον πύρ"
[505] Ks. Fredegarii Chron. 48; Pauli. Diac. IV 40; Schlözer, Nestor,
II siv. 113; vertaa Schafarik, Slaw. Altherth., II siv. 59.
[506] Ks. Theophan. Chronogr., ed. Bonn., sivv. 485 seurr.: "οι
Χαζάροι", "οι Χαζάρεις." Arapialaisilla nimi kuului: "Khasar",
Slavilaisilla: "Kosar." — Että ovat samaa kuin entiset Akazirit todistaa
selvillä sanoilla Nimetön Ravennalainen [ed. Pinder et Parthey, siv.
168]: "quos Chazaros Iordanis (s.o. Jornandes) Agaziros vocat."
[509] Ks. Zeuss, die Deutschen, siv. 726; D'Ohsson, des Peuples
du Caucase, siv. 217; Frähn, de Chazaris.
[515] Ks. ylempänä siv. 157; Constant. Porphyr., de Adm. Imp. 42.
[519] Ks. Neumann, die Völker des südl. Russl., siv. 89.
[531] Ks. Leo Gramm., Chronogr., ed. Bonn., sivv. 267, 268;
Constant. Forph., Adm. Imp. 40.
[533] Ks. Constant. Porph., Adm. Imp. 38, 42 (sivv. 170, 177).
[535] Notar. Belæ (e. 57) sanoo: "de terra Bular venerunt quidam
nobilissimi domini cum magna multitudine Hismahelitarum, quorum
nomina fuerunt Billa et Bocsu. — — Et eodem tempore de eodem
regione venit quidam nobilissimus miles nomine Heten". Nimi
Hismaelitæ ilmoittaa, että olivat Muhammedin uskoa, ja todella
mainitaankin sen-uskoisia Unkarin lakiloissa. Arapialaisen Jakutin
kertomus 13:nnelta vuosisadalta antaa tähän vahvistusta [ks. Frähn,
de Bashkiris]: "ego vero offendi in urbe Haleb magno numero genus
hominum, qui Bashgurdi audiebant, crinibus et facie valde rubicundis
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
ebookultra.com