PrintNumber ErrorLocation Error Correction DateAdded
5 p ii update print-line done 2/17/2009
5 p 23 • Line 2—The main() method is created and named. All main() methods take this format, as you’ll learn during Day 5, “Creating Classes and Methods.” For now, the most important thing to note is the static keyword, which indicates that the method is a class method shared by all VolcanoRobot objects. • Line 2—The main() method is created and named. All main() methods take this format, as you’ll learn during Day 5, “Creating Classes and Methods.” For now, the most important thing to note is the static keyword, which indicates that the method is a class method shared by all VolcanoApplication objects.
2/17/2009
5 p 40 Table 2.1  Integer Types
Type Size Values That Can Be Stored
byte 8 bits 128 to 127
short 16 bits 32,768 to 32,767
int 32 bits 2,147,483,648 to 2,147,483,647
long 64 bits 9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
Table 2.1  Integer Types
Type Size Values That Can Be Stored
byte 8 bits -128 to 127
short 16 bits -32,768 to 32,767
int 32 bits -2,147,483,648 to 2,147,483,647
long 64 bits -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
2/17/2009
5 p 56 ++ — ! ~ instanceof The instanceof operator returns true or false based on whether the object is an instance of the named class or any of that class’s subclasses (discussed tomorrow).
++ -- ! ~ instanceof The instanceof operator returns true or false based on whether the object is an instance of the named class or any of that class’s subclasses (discussed tomorrow).
2/17/2009
5 p 59 Table 2.7  Continued
Operator Meaning
— Decrement
+= Add and assign
-= Subtract and assign
*= Multiply and assign
/= Divide and assign
%= Modulus and assign
Table 2.7  Continued
Operator Meaning
-- Decrement
+= Add and assign
-= Subtract and assign
*= Multiply and assign
/= Divide and assign
%= Modulus and assign
2/17/2009
5 p 77 In many casts between primitive types, the destination can hold larger values than the source, so the value is converted easily. An example would be casting a byte into an int. Because a byte holds values from –128 to 127 and an int holds from 2,100,000 to 2,100,000, there’s more than enough room to cast a byte into an int.
In many casts between primitive types, the destination can hold larger values than the source, so the value is converted easily. An example would be casting a byte into an int. Because a byte holds values from –128 to 127 and an int holds from -2.1 billion to 2.1 billion, there’s more than enough room to cast a byte into an int.
2/17/2009
5 p 50 17: // Begin by subtracting 32
18: cel = cel * 9;
19: // Divide the answer by 9
20: cel = cel / 5;
21: // Multiply that answer by 5
17: // Begin by subtracting 9
18: cel = cel * 9;
19: // Divide the answer by 5
20: cel = cel / 5;
21: // Add 32 to the answer
2/17/2009
5 p 59 Q What happens if I assign an integer value to a variable that is too large for that variable to hold?
A Logically, you might think that the variable is converted to the next larger type, but this isn’t what happens. Instead, an overflow occurs—a situation in which the number wraps around from one size extreme to the other. An example of overflow would be a byte variable that goes from 127 (acceptable value) to 128 (unacceptable). It would wrap around to the lowest acceptable value, which is 128, and start counting upward from there. Overflow isn’t something you can readily deal with in a program, so be sure to give your variables plenty of living space in their chosen data type.
Q What happens if I assign an integer value to a variable that is too large for that variable to hold?
A Logically, you might think that the variable is converted to the next larger type, but this isn’t what happens. Instead, an overflow occurs—a situation in which the number wraps around from one size extreme to the other. An example of overflow would be a byte variable that goes from 127 (acceptable value) to 128 (unacceptable). It would wrap around to the lowest acceptable value, which is -128, and start counting upward from there. Overflow isn’t something you can readily deal with in a program, so be sure to give your variables plenty of living space in their chosen data type.
2/17/2009
5 p 92 All arrays have an instance variable named length that contains the number of elements in the array. Extending the preceding example, the variable titles.length contains the value 4. All arrays have an instance variable named length that contains the number of elements in the array. Extending the preceding example, the variable titles.length contains the value 5. 2/17/2009
5 p 95 This array of arrays contains a total of 365 integers, one for each day of the year. You could set the value for the first day of the 10th week with the following statement: This array of arrays contains a total of 364 integers, enough for 52 seven-day weeks. You could set the value for the first day of the 10th week with the following statement: 2/17/2009
5 p 97 int duration;
if (arguments.length < 1)
“‘“server = “localhost”;
else
“”server = arguments[0];
String server;
if (arguments.length < 1)
server = “localhost”;
else
server = arguments[0];
2/17/2009
5 p 109 int count = 0;
while (count < array1.length) {
if (array1[count] == 1)
break;
array2[count] = (float) array2[count++];
}
int count = 0;
while (count < array1.length) {
if (array1[count] == 1)
break;
array2[count] = (float) array1[count++];
}
2/17/2009
5 p 110 int count = 0;
int count2 = 0;
while (count++ <= array1.length) {
if (array1[count] == 1)
continue;

array2[count2++] = (float)array1[count];
} >
int count = 0;
int count2 = 0;
while (count++ <= array1.length) {
if (array1[count] == 1)
continue;

array2[count2++] = (float)array1[count];
}
2/17/2009
5 p 123 System.exit(0);
“”int now = System.currentTimeMillis();
System.exit(0);
int now = System.exit();
2/17/2009
5 p 141 A The easiest way to avoid this problem is to give your local variables the same names that your instance variables have. Otherwise, you can use this.origin to refer to the instance variable and origin to refer to the local variable.
A The easiest way to avoid this problem is not to give your local variables the same names that your instance variables have. Otherwise, you can use this.origin to refer to the instance variable and origin to refer to the local variable.
2/17/2009
5 p 154 The main() method indicates that you can run this as a Java application and test all the other methods. In the main() method, 10 instances of the InstanceCounter class are created and then the value of the numInstances class variable is displayed.
The main() method indicates that you can run this as a Java application and test all the other methods. In the main() method, 500 instances of the InstanceCounter class are created and then the value of the numInstances class variable is displayed.
2/18/2009
5 p 168 public class Monitor implements Trackable {

public Trackable beginTracking(Trackable self) {
Monitor mon = (Trackable) self;
// ...
}
}
public class Monitor implements Trackable {

public Trackable beginTracking(Trackable self) {
Monitor mon = (Monitor) self;
// ...
}
}
2/18/2009
5 p 172 Line 24 rounds off price so that it contains two or fewer decimal points, turning a price such as $6.92999999999999 to $6.99. The Math.floor() method rounds off decimal numbers to the next lowest mathematical integer, returning them as double values.
Line 24 rounds off price so that it contains two or fewer decimal places, turning a price such as $6.92999999999999 to $6.99. The Math.floor() method rounds off decimal numbers to the next lowest mathematical integer, returning them as double values.
2/18/2009
5 p 213 You learned how to actually create and throw your own methods by defining new exception classes and by throwing instances of any exception classes using throw.
You learned how to actually create and throw your own exceptions by defining new exception classes and by throwing instances of any exception classes using throw.
2/18/2009
5 p 227 Because vectors are zero-based, the first call to get() retrieves the “Pak” string, and the second call retrieves the “Han” string. Just as you can retrieve an element at a particular index, you also can add and remove elements at an index by using the add() and Because vectors are zero-based, the first call to get() retrieves the “Pak” string, and the second call retrieves the “Inkster” string. Just as you can retrieve an element at a particular index, you also can add and remove elements at an index by using the add() and 2/18/2009
5 p 293 The ProgressMonitor application uses a are progress bar to track the value of the num variable. The progress bar is created in line 18 with a minimum value of 0 and a maximum value of 2000.
The ProgressMonitor application uses a progress bar to track the value of the num variable. The progress bar is created in line 18 with a minimum value of 0 and a maximum value of 2000.
2/18/2009
5 p 311 The second argument is a BorderLayout class variable that indicates to which part of the border layout to assign the component. The variables NORTH, SOUTH, EAST, WEST, and CENTER can be used.
The second argument to this method is the component that should be added to the container.
The second argument is a BorderLayout class variable that indicates to which part of the border layout to assign the component. The variables NORTH, SOUTH, EAST, WEST, and CENTER can be used.

2/18/2009
5 p 312 The following statement adds a button called quitButton to the north portion of a border layout:
add(quitButton, BorderLayout.NORTH””);
The following statement adds a button called quitButton to the north portion of a border layout:
add(quitButton, BorderLayout.NORTH);
2/18/2009
5 p 336 public void actionPerformed(ActionEvent event) {
Object source = evt.getSource();
}
public void actionPerformed(ActionEvent event) {
Object source = event.getSource();
}
2/18/2009
5 p 377 • Line 63 sets the current color to black. This replaces the gradient fill pattern for the next drawing operation because colors are also fill patterns.
• Line 65 creates a new BasicStroke() object with no arguments, which defaults to a 1-pixel line width.
• Line 66 sets the current line width to the new BasicStroke object pen2.
• Line 65 sets the current color to black. This replaces the gradient fill pattern for the next drawing operation because colors are also fill patterns.
• Line 66 creates a new BasicStroke() object with no arguments, which defaults to a 1-pixel line width.
• Line 67 sets the current line width to the new BasicStroke object pen2.
2/18/2009
5 p 383 To see it in action, visit Sun’s Java Web Start site at http://java.sun.com/products
/javawebstart and click the Code Samples & Apps link, and then the “Demos” link. The Web Start Demos page contains pictures of several Java applications, each with a Launch button you can use to run the application, as shown in Figure 14.1.
To see it in action, visit Sun’s Java Web Start site at http://java.sun.com/javase/
technologies/desktop/javawebstart/downloads/archive-download.html and click the Code Samples & Apps link, and then the “Demos” link. The Web Start Demos page contains pictures of several Java applications, each with a Launch button you can use to run the application, as shown in Figure 14.1.
2/18/2009
5 p 425 The SourceReader application’s output is the text file SourceReader.java.
The SourceReader application’s input is the text file SourceReader.java.
2/18/2009
5 p 449 Reflection is most commonly used By using reflectionby tools such as class browsers and debuggers as a way to learn more about the class of objects being browsed or debugged.
Reflection is most commonly used by tools such as class browsers and debuggers as a way to learn more about the class of objects being browsed or debugged.
2/18/2009
5 p 469 int[] temps = { 90, 85, 87, 78, 80, 75, 70, 79, 85, 92, 99 };
IntBuffer tempBuffer = IntBuffer.allocate(temperatures.length);
for (int i = 0; i < temps.length; i++) {
float celsius = ( (float)temps[i] - 32 ) / 9 * 5;
tempBuffer.put( (int)celsius );
};
tempBuffer.position(0);
for (int i = 0; tempBuffer.remaining() > 0; i++)
System.out.println(tempBuffer.get());
int[] temps = { 90, 85, 87, 78, 80, 75, 70, 79, 85, 92, 99 };
IntBuffer tempBuffer = IntBuffer.allocate(temps.length);
for (int i = 0; i < temps.length; i++) {
float celsius = ( (float)temps[i] - 32 ) / 9 * 5;
tempBuffer.put( (int)celsius );
};
tempBuffer.position(0);
for (int i = 0; tempBuffer.remaining() > 0; i++)
System.out.println(tempBuffer.get());
2/18/2009