The errata list is a list of errors and their corrections that were found after the product was released.
The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.
Color Key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update
Version |
Location |
Description |
Submitted by |
Date submitted |
|
36
method add() |
Vulnerability in add() causes exception in the [admittedly extreme] case where the code executes:
myIntList.clear(); // removes all entries, so size now = 0
myIntList.trim(); // sets capacity = size = 0
myIntList.add(49); // or any valid int doubles capacity 0 to yield 0, then attempts to insert index 1 causing exception.
Suggested correction (could move check to setCapacity() if desired):
// Append a new value to the list, reallocating if necessary
public void add(int value) {
if (size == data. length) setCapacity((0 == data.length) ? DEFAULT_CAPACITY : size*2); // realloc if necessary
data[ size++] = value; // add value to list
}
|
Richard L. King |
Mar 19, 2010 |
Printed |
Page 517
bottom |
On class PlayerPiano in book Java Examples in a Nutshell, 3rd Edition, on Java and Sound, Part 2
I ran into this code:
static final int[ ] offsets = { // add these amounts to the base value
// A B C D E F G
-4, -2, 0, 1, 3, 5, 7
};
When played the example string "A B C D E F G +A s/32 D E C D E C /1-->>CEG" plays actually C D E F G H A B, and then in the end plays a EGB chord (E-minor).
The right code should be:
static final int[ ] offsets = { // add these amounts to the base value
// A B C D E F G
-3, -1, 0, 2, 4, 5, 7
};
because the offsets are on semi-tones, and these are the correct musical offsets. Namely, note A is 3 semitones lower than C, note B is one semitone lower than C and
so forth.
|
Anonymous |
May 12, 2010 |
Printed |
Page 574
1st paragraph |
1) http://localhost:8080/je3/HelloNet
should read:
http://localhost:8080/je3/Hello
2) It then follows that
http://localhost:8080/je3/HelloNet?username=David
should read
http://localhost:8080/je3/Hello?username=David
-This is based of the web.xml included with these examples.
|
Anonymous |
|
Other Digital Version |
699
Example 1-12 (FactQuote.java) |
The sample code does not compile on MacOS (at least)
>javac FactQuoter.java
>FactQuoter.java:33: cannot find symbol
symbol : variable Factorial4
location: class je3.basics.FactQuoter
System.out.println(x + "! = " + Factorial4.factorial(x));
^
1 error
Please note that I am reading on Kindle, therefore the page number above is actually a kindle location. You don't have a way to specify this.
|
Anonymous |
Jun 30, 2010 |