Java Gently Error List

for the Third Printing (contains the words "reprinted 1998 (twice))" on page iv
For the second printing, look at this list.


Chap Page Line
Change
2
21
4
replace by f.setVisible(true);
3
78
22
replace fields1 by field1
3
79
22
replace fields2 by field3
4
114
Output
remove one asterix from both sides of the heading (only 5 asterisks in code)
message should read:
Enter a cheque number of ten digits separated by a space and ending with a return
4
118
-14
replace line by Type numbers, ending with control-D (unix) or control-Z (Windows)
4
118
-7
replace 'The total is 63.0' by 'The total of the 5 numbers is 63.0'
4
121
11
remove BufferedReader
5
137
-12
remove quotation mark at then end of the line
5
141
3
replace '***** Controlling an apparatus *****' by '***** Controlling an engine *****'
5
142
-3
insert System.out.println("What is the target number? ");
between BufferedReader in = ... and try {
5
143
1
insert 
System.out.println("Try to hit the target");
int number = 0;
between try { and do {
5
143
3
remove int from int number = ...
5
143
5
insert System.out.println("You got it!");
between '} while (number != ...' and '}' on line 5
6
159
5
insert import javagently.* before import java.util.Random;
6
159
-17&-16
on both lines, enclose Text.writeInt(...) statement by a System.out.print(...) statement
(e.g. System.out.println(Text.writeInt(i, 6)))
6
166
11
replace line by  int noofJudges;
6
166
16
add a semi-colon at then end of the line
6
167
1
add import java.io.*; before import javagently.*;
6
171
4
replace DataInputStream by BufferedReader in parameter block
6
171
26
add System.out.println("  "); between System.out.println(); and
for (int i=0; i<rowmax; i++)
6
172
7
insert BufferedReader fin; between System.out.print(... and try {
6
172
8 & 10
delete BufferedReader
6
172
11
replace line by System.out.println("Using my own test map gold.dat");
6
176
-20
change startyear to startYear and endyear to endYear
6
177
17
replace line by Data read in for 1987 to 1994
6
181
-11&-12
switch these two lines around, so they read
if (i>0 && i % 7 == 0) System.out.println();
System.out.print(a[i]+"\t");
6
182
Output
There should now only be 7 columns of symbols.
6
188
1
replace line by * Stores names and 6 marks
6
189
16
add a semi-colon to the end of the line
6
189
17
remove the extra opening bracket.  Line is now System.out.println(result.intValue());
6
189
-22
replace line by In the table are
7
206
-1 & -2
change system to System
8
239
-8
replace instock by inStock
8
246
12
replace Clonable by Cloneable
8
258
-19
insert import myutilities.*; beneath import java.text.*;
8
260
20
insert import myutilities.*; beneath import java.text.*;
8
246
-3
replace Clonable by Cloneable
9
272
-13
insert keyword public beofre interface Sortable {
9
276
12&-11
add a closing brace (}) on line 12, and remove the one on line -11 
(i.e. break the class into two, in the same file)
9
298
-11
remove quotation mark from inside new GraphicWarning(");
10
309
-15
The declaration of ButtonTest should exclude the title parameter, i.e. 
public ButtonTest (String[] message, int n) {
10
312
-7
remove the title parameter
10
312
-5
remove the call to super(title)
10
313
3
replace line by Panel p = new Panel();
10
315
17
remove the call to setTitle("Traffic Lights version 0");. It's called later in main.
10
315
19
replace panel by Panel
10
315
20
replace line by title.add(new Label("Savanna Traffic Light Simulation"));
13
382
9
insert
import java.awt.*;
import.awt.event.*;
before class SetOfLights...
13
400
-12
insert the following method:
static int a(int x) {
  return (int)(Math.random()*x)+1;
}
14
415
-3 & -7
replace out.println(...) by conout.println(...)
14
415
-11
replace String s = in.readLine(); by String s = conin.readLine();
14
416
2
replace out.println(...) by conout.println(...)
15
457
-18
The item class is taken from example 15.1, and needs to be modified to handle int's, not char's.
item (int i) {
  data = i;
}
int data;
15
462
-17
insert the following method:
public boolean more (Object x) {
  return (height > ((Student)x.height);
}
15
466
1
insert the following method:
public boolean more (Object x) {
  return (height > ((Student)x.height);
}
ans
480
17
replace here by there
ans
480
-7
replace variable by constant



Last Updated on 23 May 2000
Email: javagently@cs.up.ac.za