On the bottom of the copyright page (facing the first page of the table of
contents), look for a line such as
First printing, April 2008
In the errata below, we indicate the printing in which the error has been
fixed inside square brackets such as [4].
For example, suppose you have the fourth printing. Then you can ignore all reports that are prefixed with [2], [3] or [4]. But you would want to pay attention to all reports that are prefixed with [5] or higher or that have no bracketed prefix at all.
float
to double
You can move backwards with the following statements:
i--; if (Character.isSurrogate(sentence.charAt(i))) i--; int cp = sentence.codePointAt(i);
copyTo
method” to “the
copyOf
method”static int binarySearch(type[] a, int start, int
end type v)
to static int
binarySearch(type[] a, int start, int end, type
v)
(i.e. add the comma)
Change static type copyOf(type[] a, int
length)
to static type[] copyOf(type[] a,
int length)
Change static type copyOf(type[] a, int start,
int end)
to static type[]
copyOfRange(type[] a, int start, int end)
balance
” to “array
balance
s” and balance[0].length
to
balances[0].length
birthday
to deadline
MyProg.java
to MyProg
(2x)manager[0]
to managers[0]
and
manager[i]
to managers[i]
list.add(new Integer(3));
to
list.add(Integer.valueOf(3));
Size s = (Size) Enum.valueOf(Size.class, "SMALL");
to
Size s = Enum.valueOf(Size.class, "SMALL");
if (!r.endsWith("[")) r += ","
cloned.hireDay = (Date) hireDay.clone()
return super.clone();
to
return (Employee) super.clone();
int[] cloned = (int[]) luckyNumbers.clone();
to
int[] cloned = luckyNumbers.clone();
javax.awt.Toolkit
to
java.awt.Toolkit
Proxy.newInstance
to
Proxy.newProxyInstance
EventQueue.invokeLater(new Runnable() { public void run() { SimpleFrame frame = new SimpleFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } });
Then add a line at the top of the file
import java.awt.*;
setLoationByPlatform(true);
to
setLocationByPlatform(true);
NotHelloWorldComponent comp = new NotHelloWorldComponent(); add(comp);
In line 45, change “panel” to “component”
Change line 47 to
class NotHelloWorldComponent extends JComponent
class ButtonPanel extends JFrame
to
class ButtonFrame extends JFrame
}
below repaint();
that lines up with
the {
below the if
.JComponent
is a subclass of
Container
not Component
, and therefore”
to ”Moreover, JComponent
is a subclass of
Container
, not Component. ThereforeGridLayout(5, 4)
to GridLayout(4,
4)
Border etched =
BorderFactory.createEtchedBorder()
“returnfalse
” to
“returnBoolean.FALSE
”appletviewer NotHelloAppletApplication.java java NotHelloAppletApplication
to
appletviewer AppletApplication.java java AppletApplication
applet = anApplet Container contentPane = getContentPane(); contentPane.add(applet);
to
applet = anApplet; add(applet);
String[] keys
to String[] keys()
try()
to try
OutputStream
to PrintSteam
(EmptyStackException s)
to
(EmptyStackException e)
setColor(Color.yellow)
to
setBackground(Color.yellow)
String filename = (String) names.get(0);
to
String filename = (String) files.get(0);
public static <T> T getMiddle(T[] a)
to
public static <T> T getMiddle(T... a)
and
String[] names = { "John", "Q.", "Public" }; String middle = ArrayAlg.<String>getMiddle(names);
to
String middle = ArrayAlg.<String>getMiddle("John", "Q.", "Public");
and
String middle = ArrayAlg.getMiddle(names);
to
String middle = ArrayAlg.getMiddle("John", "Q.", "Public");
DateInterval
class”. Change // defined
in Pair
to // overrides the method defined in Pair to
call the first method
// same as a instanceof Pair
and // T is
ignored
to // ERROR
. Change “really only
tests” to “could only test”. Change “compiler
warning whenever you use instanceof
or cast expressions that
involve generic types.” to “compiler error (with
instanceof
) or warning (with casts) when you try to inquire
whether an object belongs to a generic type.Object[2]
” to “an array
Comparable[2]
”minmax(T[] a)
to minmax(T... a)
(2x).
Change “is assigned to the String[] variable” to “is
cast to Comparable[]
as the method returns.”setFirst
method but can call it with any object of type
Manager
, Employee
, or Object
, but
not a subtype such as Executive
. However,” to
”The compiler doesn’t know the exact type of the
setFirst
method and therefore can't call it with an object
of type Employee
or Object
, but only with type
Manager
or a subtype such as Executive
.
Moreover,”setObject
method” to
“you can call the setFirst
method”null
reference.”contains
into” to
“turning hasNulls
into”WildCardType
, flip the headers •
Type[] getLowerBounds()
and • Type[]
getUpperBounds()
, but not the text below. (I.e.
getUpperBounds
gets the extends
bounds.)PairAlg.swapHelper(result);
to
PairAlg.swap(result);
: c
to :
this
. In the second line of page 657, remove the =
inreturn = true;
for (int i = 1; i <= 20 && iter.hasNext(); i++)
V get(K key)
to
V get(Object key)
null
keys.”
Change “The key may be null, but the value must not be
null.” to “Implementing classes may
forbid null
keys or values.”
ncopies
" to "unlike
nCopies
".});
to };
elements
extends the
AbstractSequentialList
class” to “the element
type implements the RandomAccess
interface”. Change
MenuItem
to JMenuItem
(6x)menu.addItem(item)
to menu.add(item)
(2x)item.getItem(i)
to item.getItem(i)
and
item.getItemCount()
to menu.getItemCount()
.addBall
method has returned."* @aBall the ball to bounce * @aPanel the component in which the ball bounces
to
* @param aBall the ball to bounce * @param aComponent the component in which the ball bounces
public static final int STEPS = 1000; public static final int DELAY = 3;
from BounceThread.java
Thread().currentThread().interrupt()
to
Thread.currentThread().interrupt()
getDefaultExceptionHandler
to
getDefaultUncaughtExceptionHandler
null
is actually a literal, not a keyword.)out.write(value);
to
out.write(original);
boolean exclusive
to boolean shared
(2x). Change “The exclusive flag is true” to “The
shared
flag is false
” and “It is
false
” to “It is true
”.RegexTest
to
RegExTest
to match the file name"<a\\s+href\\s*=\\s*(\"[^\"]*\"|[^\\s>])\\s*>"
to
"<a\\s+href\\s*=\\s*(\"[^\"]*\"|[^\\s>]*)\\s*>"
Ù
to é
constraints.gridx = Integer.parseInt(value);
to
constraints.gridy = Integer.parseInt(value);
<xsd:schema xmlns:xsl="http://www.w3.org/2001/XMLSchema">
to
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
@param c the counter for the handlers (used
in prompts)
while (in.hasNextLine()) != null)
to while
(in.hasNextLine() != null)
String encoding = base64Encode(input);
to
String encoding = base64Encode(input).trim();
(Apparently, some servers don't like a final \n in the URL encoded string.)
getAllowsUserInteraction()
to
getAllowUserInteraction()
Map<String,List<String>> Map
getHeaderFields()
to
Map<String,List<String>> getHeaderFields()
Change String getContentType
to String
getContentType()
. - * _
unchanged” to “and
. - _ ~
unchanged”CREATE TABLE Publisher
to CREATE TABLE
Publishers
Change @Resource("jdbc/corejava")
to
@Resource(name="jdbc/corejava")
sp
” to “Spanish
es
”event.isAdjusting()
to
event.getValueIsAdjusting()
JLabel label = new JLabel();
else setBorder(null); } return this;
to
else setBorder(null); return this; }
super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
to
Component comp = super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
and
setFont(font); return this;
to
comp.setFont(font); return comp;
skewedAngle = Math.toDegrees(Math.atan2(x * width, y * height));
to
skewedAngle = Math.toDegrees(Math.atan2(-y * height, x * width));
FileNameBean
has a filename
property and
an indexed extensions property
”IndexedPropertyChangeEvent(Object sourceBean, String propertyName, int index, Object oldValue, Object newValue)
to
IndexedPropertyChangeEvent(Object sourceBean, String propertyName, Object oldValue, Object newValue, int index)
PropertyDescriptor descriptor = new PropertyDescriptor("fileName", ImageViewerBean.class);
to
PropertyDescriptor descriptor = new PropertyDescriptor("fileName", FilePickerBean.class);
class ImageViewerBeanBeanInfo extends SimpleBeanInfo { public PropertyDescriptor[] getPropertyDescriptors() { return propertyDescriptors; } private PropertyDescriptor[] propertyDescriptors = new PropertyDescriptor[] { new PropertyDescriptor("fileName", ImageViewerBean.class); }; }
to
public class ImageViewerBeanBeanInfo extends SimpleBeanInfo { private PropertyDescriptor[] propertyDescriptors; public ImageViewerBeanBeanInfo() { try { propertyDescriptors = new PropertyDescriptor[] { new PropertyDescriptor("fileName", FilePickerBean.class); } } catch (IntrospectionException e) { e.printStackTrace(); } } public PropertyDescriptor[] getPropertyDescriptors() { return propertyDescriptors; } }
UnixPrincpal
to NTUserPrincipal
in AuthTest.policy
and UnixLoginModule
to NTLoginModule
in jaas.config
” Then use a SecretKeyFactory
, like this:
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("AES"); byte[] keyData = . . .; // 16 bytes for AES SecretKeySpec keySpec = new SecretKeySpec(keyData, "AES"); Key key = keyFactory.generateSecret(keySpec);
to
Then construct a SecretKeySpec
(which implements the
SecretKey
interface) like this:
byte[] keyData = . . .; // 16 bytes for AES SecretKey key = new SecretKeySpec(keyData, "AES");
engine.eval("f.text = ’Ok’");
to
engine.eval("b.text = ’Ok’");
@BugReport(reportedBy={"Harry", "Carl"}))
to
@BugReport(reportedBy={"Harry", "Carl"})})
@Inherited @Persistent { }
to
@Inherited @interface Persistent { }
fieldID
is a value” to “Here,
fieldID
is a value”.
Change “There are two ways to obtain the class object.” to
“To obtain the fieldID
, you must first get a value
representing the class, with you can do in one of two ways.”
Thanks to Yasir Bajwa, Chad Bamford, Chris Bolliger, Fred Brasch, Jonathan Camilleri, Francisco Gómez Carrasco, Lynn Robert Carter, Mark Chamberlin, Arnab Dutta Chowdhury, Joseph Collins, Chris Colvard, Dawid Czesak, Matthew Dempsky, Manoj Dongare, Peter Drake, Greg Drysdale, Douglas Eddy, Michael Forster, Louis Fuka, Angelo Furfaro, Bob Gabriels, Mircea Grecu, Siegmar Gross, Richard Hall, David Hinkle, Ernie Homsy, Richard Howard, Zhang Hui, Chongwei Jin, James Johnson, Dale Jones, Ahmed Khademzadeh, Patrick Kik, George Kollias, Ashok Kumar, Robert Kwan, David Lanznar, Larry LaPointe, Jeppe Warberg Larsen, Daniel Lazzari, Cendey Lee, James Lee, Steffen Lehmann, David Lyng, Qichan Ma, Irina Marudina, Marijan Matic, Vincenzo Mele, Hildeberto Mendonça, Christian Mrugalla, Thejas Nair, Thomas Naumann, Raul Palma, Jeremy Palmer, David Pan, Ian Patterson, Diego Pérez, Bojan Petrovic, Łukasz Piwko, Boaz Porat, Philip Puryear, Paul Pype, Derek Raimann, Etienne Richard, Dave Richards, Ken Rocha, Michael Roper, Vickram Sawh, Daniel Schuler, David Sletten, Zheng Song, Raj Subramanian, Greg Szpetkowski, Shunsuke Takamiya, Kenya Tanaka, Viktor Toman, Jim Tuller, Ingo Turnwald, Abhishek Vaid, Jan-Petter Vainionpää, Iurii Volchyn, Tielman de Villiers, R. Wahl, Andrew Wan, Brian Wongchaowart, Kim Ming Yap, Mark Yasuda, Liang Yong, YanNi Yu, Yong Yu, Talal Zaidy, Keoki Zee, Jenny Zhou, Dejan Zivkovic, Steven Zollo, and (your name might go here) for their bug reports!
Please report any remaining bugs in this edition on the bug report form.