Computing Concepts with Java Essentials

{short description of image}

This page refers to the out-of-print first edition of the book. There is now a second edition.

Bug Report Page

Book Errata

* = corrected in the second printing

# = corrected in the third printing

*Page 22 Line 7
"keyword" should be "word"
*Page 36
In Exercise R1.16, change "Every month, $500 is withdrawn to meet college expenses" to "Every month, $500 is withdrawn to meet college expenses after the interest has been credited."
*Page 37
Change System.out.print(userName) to System.out.print(userInput)
#Page 42 first paragraph
Change "Names must start with a letter, and the remaining characters must be letters, numbers or the underscore (_) character. You cannot use other symbols such as $ or %." to "Names can be made up of letters, digits, $ and the underscore (_) character. They cannot start with a digit, though.You cannot use other symbols such as ? or %."
*Page 52 last line
Change total = count * 0.05 + total to total = total + count * 0.05
*Page 55
Change int n = (int)(100 * (x - y)); to int n = (int)(100 * (f - g));
#Page 61
Remove the sentences "The % operator can be applied only to integers, not to floating-point values. For example, 7.0 % 4 is an error."n
*Page 72 Line 11 from bottom
Change "the string Pennies" to "the string Pennies |"
*Page 77 Exercise R2.11
After "True or false?" add: (x is an int and s is a String.)
#Page 78-79, Exercise R2.17
Remove semi-colons at the end of the expressions in parts (d), (f), (g) and (h).
#Page 84, Exercise P2.20
Change double x1 to int x1 and double x2 to int x2
*Page 89
2000 2 12 should be: 2000 1 12
*Page 89
Change "That is, February 12, 2000" to "That is, January 12, 2000"
#Page 91, Table 1
Remove ">= 1970" after "Constructs the time with year y. Change the y to y in TT style.
*Page 98
Change
java MyProg.java
to
java MyProg
*Page 113 Table 8
clear() should be clearWindow()
*Page 113
In Click.java, change draw to draw() (3 times)
#Page 125 Exercise R3.9
Change
Time dueDate  = new Time(1997, 5, 31, 12, 0, 0);
to
Time dueDate  = new Time(1997, 5, 31);
#Page 126 Exercise R3.14
Change Circle c(new Point(1,2),3); to Circle c = new Circle(new Point(1,2),3);
#Page 127 Exercise P3.8
Change "average salaries of the employees." to "average salary of the employees."
*Page 136 Sixth line from bottom
Change < 0 to > 0
*Page 137
The /* Error */ after if (p.equals(q)) . . . should be omitted!
*Page 146
In Coins6.java, change value = value * 0.25 to value = n * 0.25
Page 164
Change "Variables of type boolean can hold exactly two values" to "Variables of type boolean can hold exactly one of two values".
#Page 168 Exercise R4.1
Change if (x && y == 0) new Point(0,0).draw; to if (x && y == 0) new Point(0,0).draw();
#Page 168 Exercise R4.1
Change or to || (3x)
#Page 168 Exercise R4.1
Add a semicolon after language = "English"
#Page 168 Exercises R4.3 and R4.4
Change if/else/else to if/else if/else
#Page 171 Exercise R4.16
Change "two objects of type Line represent the same when displayed" to "two objects of type Line represent the same line when displayed"
*Page 171/172 Exercise R4.21
Change and to && (3 times)
*Page 173 3rd Formula
Add a / between r and the root of q3.
#Page 173 Exercise P4.5
change "As in Exercise P3.7" to "As in Exercise P3.11"
#Page 176 Exercise P4.18
The balance printing option is clumsy. Change the wording as follows: "Then ask for the transactions; options are deposit, withdrawal, transfer and printout of the account balance." Remove the final sentence "If the transaction was 0, print the balance of both accounts."
Page 179
Change "... then the the initial investment ..." to "... then the initial investment ..."
*Page 189 1st line Inside.java
Omit static in public static boolean isInside
*Page 209
Change "and c has changed to c / 100 or 16." to "and c has changed to c % 100 or 16."
#Page 225 Exercise P5.6.
Remove semi-colons at the end of each function header (6x).
Page 227 Exercise P5.13
In the equaltion for int jul, change d to jd.
#Page 229, Exercise P5.20
Change "If n < 0, xn is 1/(xn)." to "If n < 0, xn is 1/(x-n)."
#Page 245
Change filename.substring(i, i + 1) != '.' to !filename.substring(i, i + 1).equals(".")
#Page 262 Figure 1
A green needle is missing from the figure.
*Page 262
Change "returns a random integer between a and b" to "returns a random integer between the integersa and b", and change "returns a random floating-point number between a and b" to "returns a random floating-point number between the floating-point numbersa and b"
#Page 263
Change yhigh = ylow + cos(alpha) to yhigh = ylow + sin(alpha)
Page 271
Change x to xold (4 times)
*Page 272
Replace the second paragraph ("If the scopes...pieces of code") with
"When you combine different pieces of code, it can happen that the same variable name is used in two different scopes. Here is an example from the program that prints a table of future values."
Replace the third paragraph "This is not an error..." with
"In Java, this is an error. You cannot have variables with overlapping scopes. But in many other programming languages, this is not an error. In those languages, the variable name always refers to the closest definition. For example, in the second for loop, the inner year masks the outer one. This behavior can lead to misunderstandings, and hence Java does not allow it."
Page 272
In the third paragraph, change "You cannot have variables with overlapping scopes." with "You cannot have variables of the same name with overlapping scopes."
*Page 275 middle of page, after "On the other hand, if i is odd, then"
Replace "rnew = rold·aold" with "rnew = rold·bold"
*Page 278 Exercise R6.5
Change s = 1 / (1 + 1.0/(n * n)); to s = 1.0 / (n * n);
Page 331 line 10
The second implicitParameter should be in italics.
*Page 362/363 Problem R8.22
Replace the first four lines of the program with:
public static void main(String[] arg)
{  A a = new A();
   A b = new A(2);
   A c = b;
#Page 374
Change "Program BarGraph1.java" to "Program BarGraph.java"
#Page 378, 379 (same error occurs on both pages)
Below staff.addElement(e), change the } to
   more = readString("More? (Y/N)");
} while (more.toUppperCase().equals("Y")); 
Page 379 4th line from bottom
Change new Employee[v.size()] to new Employee[staffVector.size()]
Page 383 line 6, RaiseSalary.java
Change public static void raiseSalary to public static void raiseSalaries
*Page 383 line 11, RaiseSalary.java
s[i].getSalary(newSalary) should be s[i].setSalary(newSalary)
#Page 385 Par. 1, line 1
data[i] should be staff[i]
*Page 385 Par. 1, line 2
data.string should be staff.length
#Page 398
Change new double[6][11] to new double[11][6]
Page 400 line 2
Change the entry in the last vector from 1 to -1.
Page 403
In the second equation, change the last column of the third matrix to have entries -4, -3, and 1. Do the same for the second matrix in the third equation.
Page 438
Change long int filelength = f.length(); to long filelength = f.length();
#Page 466
Change "It must be placed into a subfolder, eval,..." to "It must be placed into a subfolder, expr,..."
#Page 472 Exercise R11.1
Change "Plot1.java and Plot2.java" to "PlotData1.java and PlotData2.java"
#Page 472 Exercise R11.5
Append: "List only the packages with two name components such as java.beans. You can omit those packages with three or more name components such as org.omg.CORBA.
#Page 472 Exercise R11.7
Change EmplFile.java to Database.java
#Page 473 Exercise R11.8
Change EmplFile.java to Database.java
#Page 473 Exercise P11.2
Change Plot2.java to PlotData2.java
*Page 482
In the second paragraph in 12.3 the first sentence should be "Let n be the size ..."
#Page 483
Change the fraction "n(n-1)/2" to "n(n+1)/2" (2 times)
#Page 501 4th line from bottom
Change v.length() to v.length
#Page 506 Exercise R12.16
Remove the initial "7" from all three sequences
#Page 506 Exercise P12.6
Change "sort it by product name" to "sort it by employee name"
#Page 506 Exercise P12.7
Change "if a was not found, set m to the negative of the index of the next larger value instead, or to -a.length - 1..." to "if a was not found, return -n - 1, where n isthe index of the next larger value, or -v.length - 1..."
#Page 507 Exercise P12.10
Change "Use a stack to keep track of which subarrays have been sorted" to "First compute the bounds of the subarrays that need to be merged and store them in an array."
#Page 523
Remove the sentence "You will find the code in the ccj package.
#Page 524
Remove the sentence "The generic linked list in the ccj package supports traversal by enumeration.
#Page 534 Exercise R13.1 and Page 535 Exercise R13.2
Change "1 Tom 1" to "1 Tom -1"
#Page 534 Exercise R13.1 and Page 535 Exercise R13.2
After the table, add:: "The head of the list is at index 2."
#Page 537 Exercise P13.2
Change "Use the reference implementation" to "Use the implementation of section 13.2".
#Page 538 Exercise P13.6
Remove the sentence "Supply a constructor that makes a polynomial from a single term." Replace the four lines of code below with the following five lines of code:
Polynomial p = new Polynomial();
      p.insert(-10, 0);
      p.insert(-1, 1);
      p.insert(9, 7);
      p.insert(5, 10);
#Page 539 Exercise P13.12
Append to the end of the exercise: "In this exercise, do not consider operator precedence. Note that this tree is not a search tree. Instead of using insert to insert strings in sorted order, supply a constructor that makes a tree from two subtrees.
#Page 528
change public EmployeeTree(); to public EmployeeTree(){}
#Page 528
change if (newRecord.data.getName().compareTo(data.name() < 0) to if (newRecord.data.getName().compareTo(data.getName() < 0)
#Page 542
Change "namely, the Clock class of Chapter 9" to "namely, the Clock class of Chapter 8"
#Page 586
Add two rows to the table of string operations in the middle of the page:
s.equals(t) true if s and t are equal
s.compareTo(t) a negative value if s comes before t in dictionary order, 0 if they are equal, a positive value otherwise
Page 591
Change randomFloat to randomDouble

Fixed CCJ Library Bugs

GraphicsApplet
The clearWindow function did not work.
GraphicsApplet
The mouse coordinates did not work until at least one graphics element was drawn.
GraphicsApplet
Some compilation environments complained that the Shape class was defined inside GraphicsApplet. It is now in a separate file, as is GraphCoord. (Originally, I put them inside GraphicsApplet because they are never explained in the text, and I felt it was best to hide their existence.)
GraphicsApplet
The 1.1 applet viewer draws the status line over the bottom of the applet until you resize the applet. I added a blank label so that it doesn't overwrite the input field. This is a workaround for a Java 1.1 bug.
GraphicsApplet
Called getSize on the canvas object, which is not compatible with Java 1.0. Replaced with call to size which is available in 1.0.
GraphicsApplet
Made setCoord a static method.
Circle, Line, Message
These classes now clone the points supplied in the constructor and the points returned in the accessor methods. Thus, the objects won't change if the points are moved.
TextOutputStream
Printing the largest negative long integer -9223372036854775808L printed out two minus signs
TextOutputStream
Printing numbers that were closer to 1 than the number of requested decimal places rounded down rather than up, e.g. formatting 1.999 with %.2f printed 1.00. (This one is pretty serious, of course.)
TextOutputStream
Printing with precision 0 (e.g %10.0f) caused a stack overflow.
TextInputStream
Some version of Microsoft J++ incorrectly assume that '\r' is not a white space. A workaround has been provided that enables ccj to work with a Microsoft virtual machine that exhibits this erroneous behavior.
In Java 1.1, under Windows, the readLine function read an extra \r. This is now fixed so that the code works uniformly with Java 1.0, 1.1, Windows, the Mac and Unix. This is a workaround for a Java 1.1 bug.
Time
The constructor Time(int y, int m, int d, int hr, int min, int sec) set the month too high by one.
Point, Circle, Line, Message, Employee
These classes now support default constructors and thus follow the recommendation in the text that all classes ought to have default constructors.

These bugs are all fixed in the current code distribution.

Thanks to Olivier Baby, Jens Bennedsen, Subhasish Bhattacharya, David Brodie, Rebekah Canada, Arthur Charlesworth, Mel O'Cinneide, H. Conrad Cunningham, Brian Evans, David Fellows, Daniel J. C. Hurley, Charles Kiser, Dieter Kraft, Stefan C. Kremer, Stephen Lang, Stephanie Meeks, Keith Meier, Suzanne Menzel, Jonathan Mohr, Geof Pawlicki, Tim Pointon, Stuart Reges, Marie A. Roch, Warren Seltzer, Eric Senn, Ruth Shaw, A. Smith, Bruce Spencer, Joe Turner, Andrew Wildenberg, John Zelle and a number of anonymous contributors for their bug reports and suggestions!

Please report any remaining bugs in this edition on the bug report form.

Further Information