Imagine! Java
Programming Concepts in Context
by Frank M. Carrano
Connect with me
Errata List
Last updated on January 23, 2013.
The date after each error is the date it was posted on this list. Subsequent printings of the book will correct these errors.
If you find an error and it is not on this list, please e-mail or tweet a description of the error, the page number, and the tile of the book.
Table of Contents
Page xxiii (June 10, 2010)
The contents of the online Chapter 30 are
Binary Files of Primitive Data
Writing Primitive Data to a Binary File
Example: Creating a Binary File of Random Integers
Reading Primitive Data from a Binary File
Example: Reading a Binary File of Integers
A Problem Solved: Duplicating a Picture File
Strings in a Binary File
Binary Files of Objects
Opening, Writing, and Closing a Binary File of Objects
A Class for Creating a Binary File of Objects
A Problem Solved: Creating a Binary File of Colleges and Universities
Opening, Reading, and Closing a Binary File of Objects
A Problem Solved: Displaying a List of Colleges and Universities
Primitive Data in Object Streams
Arrays in Binary Files
Writing Arrays to a Binary File
Reading Arrays from a Binary File
Page xxiv (June 10, 2010)
The contents of the online Chapter 31 are
Basic Operations for a Random-Access File
Opening a Binary File for Random Access
Writing to a Binary File Using Random Access
Reading a Binary File Using Random Access
A Problem Solved: Encrypting a Message
A Problem Solved: Updating a Binary File of Colleges and Universities
Preliminaries
Updating Specific Enrollments
Files Whose Records Vary in Size
Recording File-Pointer Values
A Problem Solved: A Glossary of Terms
Creating the Glossary
Accessing the Glossary
Page xxiv (July 2, 2010)
The contents of the online Chapter 32 are
Creating Objects of a Generic Class
Defining a Generic Class
Examples
More Than One Generic Type
Generic Types Within an Interface
Example: A Bag of Objects
The Interface
The Class
Limitations and Constraints
Generic Types with Static Fields and Methods
Bounding Generic Types
The Java Collections Framework
The Interface Collection
The Interface Queue
The Interface Deque
Using the Class ArrayDeque
to Define a Class of Queues
Using ArrayDeque
to Define a Class of Stacks
Chapter 2
Pages 30 - 31 (June 10, 2010)
Listing 2-4: The class descriptions given as javadoc
comments in this listing and in many listings in this book appear appear first, before any import
statements. While this placement is useful in a textbook, javadoc
requires that such comments immediately precede the class header. If you plan to run javadoc
with using these classes, be sure to position the comments appropriately.
Page 34 (May 6, 2010)
Make the following correction to the program in Project 1:
In the first print
statement, add a double quote and a space as follows:
System.out.print("Think of a planet and enter its " +
Page 36 (Jan. 23, 2013)
The answer to Self-Test Question9g should be
Scanner
, BoxedApples
, String
, System
instead of
Scanner
, Apples
, String
, System
Chapter 3
Page 56 (Oct. 1, 2010)
Project 9: In the equation at the bottom of the page for the velocity, change sin v0 to sin θ0.
Chapter 4
Page 76 (Nov. 9, 2010)
In Segment 4.8, Line 4, change "blackslash" to "backslash".
Page 90 (Apr. 22, 2010)
The comment on the last brace of the program should be BuyApples
.
Page 92 (Apr. 22, 2010)
The comment on the last brace of the program should be AgeDifference
.
Page 94 (Nov. 9, 2010)
The third bullet should read "generator.nextDouble()
returns a random number of type double
... (instead of "a random integer").
Page 103 (Nov. 9, 2010)
In the answer to Self-Test Question 15, delete the two statements that call the method trim
. Although these calls do no harm, they are unnecessary.
Chapter 5
Page 252 (May 6, 2010)
Add the following hint to Exercise 10: "Hint: Call the Graphics
method getFontMetrics
."
Chapter 10
Page 284 (Jan. 23, 2013)
In Project 2, the tax rate for a single person in the 35% bracket should be 372,951 and over. The units digit 1 was omitted.
Chapter 11
Page 320 (June 10, 2010)
Exercise 7: Revise the fourth sentence as indicated:
"... each of which is given the upper corner and the length of the side of..."
Chapter 13
Page 377 (June 10, 2010)
Exercise 15: Revise the first sentence as indicated:
"Combine the do
loop given in Segment 13.13 with the while
loop ..."
Page 377 (June 10, 2010)
Exercise 19: Revise the fourth sentence as indicated:
"Two different integers are said to ..."
Chapter 14
Page 388 (June 10, 2010)
Listing 14-4 assumes that the class Square
in Listing 11-2 defines the method getSide
, even though Listing 11-2 does not show this method.
Chapter 19
Page 569 (Dec. 7, 2010)
In the last line on the page, the data type of aString
is missing. The line should be
+getFrequencyOf(aString: String): integer
Page 571 (July 2, 2010)
Segment 19.14: Replace the next-to-last sentence with
We plan to use an array in the implementation here, but structures other than an array are possible.
Chapter 22
Page 716 (August 13, 2010)
Project 1: Revise the second paragraph as follows:
Each Dot
object also has a method to make it either visible or invisible. After generating a random integer between 1 and 6 to simulate the roll of the die, you would make the apropriate dot or dots visible, thereby displaying the die's upper face as one of the previous configurations.
Page 716 (August 13, 2010)
Project 5: Revise the second sentence of the second paragraph as follows:
Players can choose squares by clicking either squares or buttons or by entering numbers in a dialog box.
Chapter 23
Page 738 (August 13, 2010)
Delete */
after the description of the parameter last
Chapter 24
Page 789 (June 10, 2010)
Exercise 7: Change the data type of the variable result
from boolean
to int
.
Page 790 (June 10, 2010)
Exercise 9: Revise the first sentence as indicated
"What is the output of the following program:"
Page 791 (June 10, 2010)
Exercise 21: In the if
statement, change the boolean expression "f <= 4
" to "n <= 4
"
Chapter 26
Page 840 (July 2, 2010)
Exercise 11: Replace the diagram with the following one:

Chapter 27
Page 873 (Apr. 22, 2010)
In the first Note, in the next-to-last line, change "composition" to "aggregation."
Page 883 (July 2, 2010)
Exercise 9: In the code for the class CollegeStudent
, the return type for the method getYear
should be int
instead of String
."
Page 884 (July 2, 2010)
Exercise 12: In the method process
, a closing parenthesis is missing from the println
statement, as indicated here:
System.out.println(aStudent.getName());
Chapter 29
Page 925 (Apr. 22, 2010)
In the problem statement, add "zip code" after "state" so that it reads "... name, city, state, zip code, and current enrollment."
Page 929 (Apr. 22, 2010)
In the second line after the Note, add the word "name" after "file" so that it reads "...represents a file name in a system-independent and ..."
Page 938 (Nov. 27, 2011)
In the fourth line from the bottom of the page, rename
should be renameTo
.
(End of errata)