On the copyright page (facing the first page of the Preface in both Big Java and Computing Concepts with Java Essentials, Third Edition), there is a printing history of the book. The printing history is a row of numbers that -- at the 1st printing -- looks like this: 10 9 8 7 6 5 4 3 2 1
At each subsequent printing, one number is removed from the end of this row of numbers to indicate which printing of the book you have. For example, the last number in the row of numbers in the 2nd printing is 2, and so on. [B2C3] = fixed in Big Java's 2nd printing [B4C3] = fixed in Big Java's 4th printing, CCJ's 3rd printing [B4C4] = fixed in Big Java's 4th printing [B5C4] = fixed in Big Java's 5th printing, CCJ's 4th printing [B6C5] = fixed in Big Java's 6th printing
http://www.openscience.com/jmol
to http://www.openscience.org/jmol
System.out.println("Hello, Dave!")
.;
system.out.println
to System.out.println
.@param
the amount to withdraw" to "@paramamount
the amount to withdraw"getName()
, getPrice()
and setPrice()
to getName
, getPrice
and setPrice
.wait
to waitForDoubling
. (There is already a wait
method in the Object
class, and we aren't allowed to change it.)wait
to waitAMonth
. (There is already a wait
method in the Object
class, and we aren't allowed to change it.)Math.toDegrees
and Math.toRadians
are switched. In the entry for atan2
, change [-π/2, π/2] to [-π, π] In the entry for atan2
, change "... x may be 0" to "... x may be 0 ) Add two lines
Math.max(x, y) |
The larger of x and y |
Math.min(x, y) |
The smaller of x and y |
newInputStreamReader
to new InputStreamReader
.ConsoleInputTest.java
MILES_TO_KM = 0.621
to MILES_TO_KM = 1.609
public double nextDigit()
to public int nextDigit()
.metMinutes
to getMinutes
Rectangle2D.Double rightRectangle = new Rectangle2D.Double(xLeft + width / 3, yTop,
to Rectangle2D.Double rightRectangle = new Rectangle2D.Double(xLeft + 2 * width / 3, yTop,
IntersectionApplet.java
final double YMAX = 50
to final double YMAX = 40
(for consistency with the code and the screen capture)private static final double YMAX = 50
to private static final double YMAX = 40
Math.max(xscale, -yscale)
to "add the call g2.setFont(g2.getFont().deriveFont(AffineTransform.getScaleInstance(1 / xscale, 1 / yscale)))
."g2.draw
from g2.draw(new Line2D.Double(xpixel(2), ypixel(0), xpixel(1), ypixel(3)))
to g2.draw(new Line2D.Double(xpixel(1), ypixel(0), xpixel(1), xpixel(3)))
.H e l l
" to "with the letters R o b
"int x = Integer.parseInt(input); if (x != null) y = y + x;
UnitConverter
..." to "Define objects of a class UnitConverter
...". Remove "(ml, l, g, kg, mm, cm, m, km)." from the question.targetBalance
to 2 * initialBalance.
InputTest.java
System.exit(0);
after line 30return data
to return
.InputTest.java
System.exit(0);
after line 29. n
(exclusive)" to "between 0 (inclusive) and 1 (exclusive)"Needle.java
tries = 0;
"i--
to i--;
for (i = 10; i > 0; i-)
... to for (i = 10; i > 0; i--)
...public Purse
to public class Purse
other.balance + amount
(or Account.balance + amount
in a bungled correction) to otherAccount.balance + amount
private static lastAssignedNumber = 0
to private static int lastAssignedNumber = 0
private static lastAssignedNumber
to private static int lastAssignedNumber
homework1.Bank
...) to (such as homework1.Bank
...), with a space after "as"/home/bwalters/homework1
to /home/walters/homework1
.Word.java
Syllables in hello: 2
to Syllables in hello: 1.
Change "That's better, but there is still a problem" to " Unfortunately, there is still a problem".new Coin("dime", 0.1)
" to "The object new Coin(0.1, "dime")
"boolean accept(Object x)
and void draw(Graphics2D g2)
.String readLine(String prompt) throws IOException
.ActionListener listener
..."final JTextField yField = new JTextField(5);;"
with "final JTextField yField = new JTextField(5);"
ButtonApplet.java
"final JTextField yField = new JTextField(5);;"
in ButtonApplet.java
with "final JTextField yField = new JTextField(5);"
Remove semicolon after inner class MoveButtonListener
.rightListener = new ButtonListener()
to rightListener = new Right ButtonListener()
makeButton(String Label, ...)
, remove semicolon after inner class ButtonListener
.ButtonApplet.java
ButtonListener
.void transfer(double amount, BankAccount other)
to public void transfer(double amount, BankAccount other)
public CheckingAccount
to public class CheckingAccount extends BankAccount
RectangleFrame.java
MoveButtonListener
class.RectangleFrame.java
MenuFrame.java
class MenuFrame extends JFrame
to public class MenuFrame extends JFrame
MenuFrame.java
generator.nextInt(2)
to generator.nextInt(3)
.MenuFrame.java
MenuFrame()
constructor, move the line pack()
to the last line (after the second menuBar.add(...)
).data[0] == 29.95
to data[0] = 29.95
.Employee[] staff;
to Employee[] employees;
a.append(b)
to a.transfer(b)
.public void draw(Graphics2Dg)
to public void draw(Graphics2D g2)
connection = u.openConnection(u)
to connection = u.openConnection()
ClassCastException
" to "can throw a ClassNotFound Exception
".BankData.java
line 28private Customer theCustomer; private Vector items;
to private Address billingAddress; private ArrayList items;
InvoiceTest.java
BankAcccount
to BankAccount
.}
with a line containing ...
PermutationGenerator.java
s.length()
to word .length()
in constructor.text.substring(1, text.length() - 1));
The last line should be text.substring(0, text.length() - 1));
text.substring(1, text.length()));
fib(5)
" to "the trace for computing fib(6)
".else return false;to
else return false; }
int n = s.find("sip");
to int n = s.indexOf("sip");
public void nextPermutation()
to public int[] nextPermutation()
. Change return;
to return a;
(2x). At the top of page 701, change } } }to
} } return a; }Remove the
...
at the end of the class definition.MergeSorter.java
Line 68while
loops" to "Note that only one of the two calls to arraycopy
".411
(under a[7]
) to 511
.public class BankAccount
to public class BankAccountimplements Comparable
BankAccount other = (BankAccount)other;
to BankAccount other = (BankAccount)otherObject;
Purse.java
, not PurseTest.java
.
import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; /** A purse holds a collection of coins.*/ public class Purse { /** Constructs an empty purse. */ public Purse() { coins = new ArrayList(); } /** Add a coin to the purse. @param aCoin the coin to add */ public void add(Coin aCoin) { coins.add(aCoin); } /** Returns a string describing the purse contents, sorted by coin value. @return the string describing the purse contents */ public String toString() { // sort the coins first class CoinComparator implements Comparator { public int compare(Object firstObject, Object secondObject) { Coin first = (Coin)firstObject; Coin second = (Coin)secondObject; if (first.getValue() < second.getValue()) return -1; if (first.getValue() == second.getValue()) return 0; return 1; } } Comparator comp = new CoinComparator(); Collections.sort(coins, comp); String r = "Purse[coins="; for (int i = 0; i < coins.size(); i++) { if (i > 0) r = r + ","; r = r + coins.get(i); } return r + "]"; } private ArrayList coins; }
class LinkedList
to public class LinkedList
class LinkedList
to public class LinkedList
(2 times)class LinkedList
to public class LinkedList
(2 times)private class LinkedListIterator
to private class LinkedListIterator implements ListIterator
remove
method. Calling remove
twice, or calling it immediately after calling add
, should always be detected as an error. In order to detect this condition reliably, previous
and position
should be set to the same value after calling remove
or add
. (The old implementation tested for previous == null
. This test did not detect the error condition when the first element of the list was removed.) Make the following changes: 1. On page 746, change "If the previous
reference is null
" to "if the previous
reference equals position
". Change "Therefore, the remove
method sets the previous
reference to null
" to "Therefore, the remove
method sets the previous
reference to position
". 2. On page 747 and on page 751 / 752 lines 144 ... 159, change the remove
method to: public void remove() { if (previous == position) throw new IllegalStateException(); if(position == first) { removeFirst(); } else { previous.next = position.next; } position = previous; }3. On page 748 and on page 751 line 137, change
previous = null;
to previous = position;
HashSetIterator
is flawed. Here is a replacement for lines 124 ... 194:
private class HashSetIterator implements Iterator { /** * Constructs a hash set iterator that points to the first element of the * hash set. */ public HashSetIterator() { current = null; bucket = -1; previous = null; previousBucket = -1; } public boolean hasNext() { if (current != null && current.next != null) return true; for (int b = bucket + 1; b < buckets.length; b++) if (buckets[b] != null) return true; return false; } public Object next() { previous = current; previousBucket = bucket; if (current == null || current.next == null) { // move to next bucket bucket++; while (bucket < buckets.length && buckets[bucket] == null) bucket++; if (bucket < buckets.length) current = buckets[bucket]; else throw new NoSuchElementException(); } else // move to next element in bucket current = current.next; return current.data; } public void remove() { if (previous != null && previous.next == current) previous.next = current.next; else if (previousBucket < bucket) buckets[bucket] = current.next; else throw new IllegalStateException(); current = previous; bucket = previousBucket; } private int bucket; private Link current; private int previousBucket; private Link previous; }
previousBucket = bucket
was inside the if
statement. Thanks to William J. Seaman for his vigilance in this matter.)Thread.MIN_PRIORITY
)" to "between 1 (or Thread.MIN_PRIORITY
)"balance + amount
to balance - amount.
WithdrawalThread.java
" to "WithdrawThread.java
"GET mach.usno.navy.mil/cgi-bin/...
to GET /cgi-bin/...
(Remove the host from the GET
command.)POST www.usps.gov/cgi-bin/...
to POST /cgi-bin/...
(Remove the host from the POST
command.)POST
" to "It expects a POST
"URLConection
to URLConnection
Product.Product_Code = Invoice_Number.Product_Code
to Product.Product_Code = Item.Product_Code
SimpleDataSource.java
String driver = props.getProperty("jdbc.driver"); url = props.getProperty("jdbc.url"); String username = props.getProperty("jdbc.username"); String password = props.getProperty("jdbc.password");
to String driver = props.getProperty("jdbc.driver"); url = props.getProperty("jdbc.url"); username = props.getProperty("jdbc.username"); password = props.getProperty("jdbc.password");
int quantity = result.getDouble("Quantity");
to int quantity = result.get Int ("Quantity");
String columnSize = metaData.getColumnDisplaySize()
to int columnSize = metaData.getColumnDisplaySize()
Statement stat = conn.getStatement()
to Statement stat = conn. create Statement()
. Change stat.commit()
and stat.rollback()
to conn.commit()
and conn.rollback()
.<zip>94085</state>
to <zip>94085</zip>
nodes.item(j)
to nodes.item(i)
.Node anAttributeNode = nodes.item(i)
to Node anAttributeNode = attributes.item(i)
<zip>94080-1098</state>
to <zip>94080-1098</
zip >
<factor> ::= <integer> || (<expression>)
to <factor> ::= <integer> | (<expression>)
(that is, remove one vertical bar)&apos
description
to address
.quantity
to number
.<point>
to </point>
.PersonBean
class, change "// name
property" to "// lastName
property".<h1>Date JSP</h1>
to <h1>Time JSP</h1>
.Simple-DataSource
to SimpleDataSource
.class = "DBConnBean"
to class = "DataSource Bean"
zonedb.jsp
ZoneDBBean.java
line 84result.getString(1)
to result.getString(1).trim()
. (Some readers had trouble with databases that padded strings with spaces.)zone.setCity(reqest.getParameter("city"));to
zone.setCity(request.getParameter("city"));
getProperties
to getProperty.
null
. (Language lawyers keep pointing out that it is not a keyword, just a literal constant.)strictfp
Use strict rules for floating-point computations" to the keyword table.static double ceil(double x)
static double floor(double x)
static int max(int x, int y)
static double max(double x, double y)
This method returns the larger of the given parameter values. Parameters: x
, y
-- Two integer of floating-point values Returns:The maximum of the parameter valuesstatic int min(int x, int y)
static double min(double x, double y)
This method returns the smaller of the given parameter values. Parameters: x
, y
-- Two integer of floating-point values Returns:The minimum of the parameter valuesvoid close()
to void commit()
.void close()
to void rollback()
.JTextArea(int columns)
to JTextArea(int rows, int columns)
.0.1100100
binary x 27" to "1.100100
binary x 26". Change "For example, the mantissa 0.1100100 is stored as 100100" to "For example, the mantissa 1.100100 is stored as 100100" Change "For example, the exponent e = 7 would be stored as 134" to "For example, the exponent e = 6 would be stored as 133" Change "100decimal = 0|100000110|10010000000000000000000single-precision IEEE" to "100decimal = 0|10000101|10010000000000000000000single-precision IEEE"Download the latest version of bigjava.zip to get the fixed files.
ch02/greeter1/GreeterTest
:ch08/log
directory:Logger.java
TaxReturn.java
, change logger.log
to logger.info
(4x)import java.util.logging.Logger;
to the top of TaxReturn.java
TaxReturn.java
, change Logger logger = new Logger();
to Logger logger = Logger.getLogger("global");
TaxReturn.java
, change Logger.assert(income >= 0);
to assert income >= 0;
-source 1.4
option.
ch10
:Thanks to Barry Adams, Chr. Bohr-Halling, Tom Box, Peter Broomhead, Lara Burton, Paul Crockett, D. Bruce Erickson, Mark Francillon, Gudmund Skovbjerg Frandsen, Jonathan Grall, Rick Giles, Thom Gillis, Deborah Hargrove, Nina Horstmann, Ulrich Karstoft Have, Rodney Hoffman, Julie Hu, David Johnson, Cindy Johnson, Asha Khakpour, Jason Khallouf, Carlos Lisbôa, Feng Ping Liu, Jamiiru Luttamaguzi, Marc Malloy, Jason Mattinson, Mary Misiaszek, Majid Mohammad, Mohamed Najmeddine, Kathleen O'Brien, Kwangshin Oh, John Pedersen, Tim Pointon, Mansour Rakhmanov, David Regan, Stan Robertson, George Rypysc, William J. Seaman, Louise Skouboe, Elin Stoevring, Charles L. Sykes, Vincent Tan, Fran Trees, Roland Veloz, Jørgen Villadsen, Andrew Watters, Stuart Williams, Jackey Yang, 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.