Welcome to the Core Java Bug List

How to Tell which Printing You Have

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.

8th Edition Volume 1 (Java SE 6)

Page 11 [2]
In Table 1-1, change the year for Version 1.4 from 2004 to 2002
Page 16
Remove “As a middle ground, we show you how to use a text editor that can call the Java compiler and run Java programs.”
Page 21
Change “(after expansion of j2sdkversion-doc.zip)” to “(after expansion of jdk-version-doc.zip)”
Page 22
Change “devlopment” to “development“
Page 28
Remove “(To compile and run this program inside a text editor or an integrated development environment, do the same as before. For example, for Emacs, choose JDE -> Compile, then choose JDE -> Run App.)
Page 33
Change the tip to: You can also run applets from inside your integrated development environment. In Eclipse, use the Run -> Run as -> Java Applet menu option.
Page 39
Remove “This is shown in Listing 3–1.”
Page 51 Figure 3-1 [2]
Add an arrow from float to double
Page 57
Change "Fortunately, ... " until the end of the section to:

You can move backwards with the following statements:

i--;
if (Character.isSurrogate(sentence.charAt(i))) i--;
int cp = sentence.codePointAt(i);
Page 69 [2]
Change “the decimal separator is a period, not a comma” to “the group separator is a period not a comma”
Page 70 [2]
Change "If the file does not exist, you can simply" to "If the file does not exist, it is created. You can simply"
Page 90 [2]
Change "This statement sets up an array that can hold 100 integers." to "This statement creates an array of 100 integers. When you create an array of numbers, all elements are initialized with 0. (Arrays of boolean are initialized with false, arrays of objects with null values.)"
Page 91
Change “Chapter 2 of Volume II” to “Chapter 13”
Page 91, 93, 100 [2]
Change "entries" to "elements" (5x)
Page 93 [2]
Change “the copyTo method” to “the copyOf method”
Page 93 Figure 3-14 [2]
Change 12 to 13
Page 98
Change 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)

Page 100
Change “array balance” to “array balances” and balance[0].length to balances[0].length
Page 103 [2]
Change "entry" to "element" (2x)
Page 107 [2]
Change “Thinking about classes as cookie cutters.” to “Think about classes as cookie cutters.”
Page 113 Figure 4-4 [2]
Change the second birthday to deadline
Page 113 [2]
Change "Variables are not automatically initialized to null." to "Local variables are not automatically initialized to null."
Page 161 [2]
Change MyProg.java to MyProg (2x)
Page 180
Change manager[0] to managers[0] and manager[i] to managers[i]
Pages 181, 185, 218 [2]
Change “runtimeruntime” to “runtime”
Page 192 [2]
Change “see Volume II for more on threads” to “see Chapter 14 for more on threads”
Page 197 [2]
Change “Chapter 2 of Volume II.” to “Chapter 13.”
Page 211
Change list.add(new Integer(3)); to list.add(Integer.valueOf(3));
Page 215
Change
Size s = (Size) Enum.valueOf(Size.class, "SMALL");

to

Size s = Enum.valueOf(Size.class, "SMALL");
Page 221
Change “private and protected members” to “private, package, and protected members”
Page 227
Add a semicolon after if (!r.endsWith("[")) r += ","
Page 252 [2]
Add a semicolon after
cloned.hireDay = (Date) hireDay.clone()
Page 253
Change
   return super.clone();

to

   return (Employee) super.clone();
Page 253
Change
int[] cloned = (int[]) luckyNumbers.clone();

to

int[] cloned = luckyNumbers.clone();
Page 258 [2]
Change javax.awt.Toolkit to java.awt.Toolkit
Page 277
Change Proxy.newInstance to Proxy.newProxyInstance
Page 286 SimpleFrameTest.java [2]
Replace lines 11-13 with
         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.*;
Page 290 [2]
Change
setLoationByPlatform(true);

to

setLocationByPlatform(true);
Page 298 NotHelloWorld.java [2]
Change lines 36 and 37 to
      NotHelloWorldComponent comp = new NotHelloWorldComponent();
      add(comp);

In line 45, change “panel” to “component”

Change line 47 to

class NotHelloWorldComponent extends JComponent
Page 299
Change “overrides this method” to “override this method”
Page 328
Change
class ButtonPanel extends JFrame

to

class ButtonFrame extends JFrame
Page 344 [2]
Change “you nee to know” to “you need to know”
Page 352
Add a } below repaint(); that lines up with the { below the if.
Page 365 [2]
In Figure 9-3, change WYSIWG to WYSIWYG
Page 369
Change “Moreover, JComponent is a subclass of Container not Component, and therefore” to ”Moreover, JComponent is a subclass of Container, not Component. Therefore
Page 373
Change GridLayout(5, 4) to GridLayout(4, 4)
Page 384
Remove lines 69 and 70
Page 392 [2]
Add a semicolon after Border etched = BorderFactory.createEtchedBorder()
Page 401 [2]
Change "See Chapter 2 of Volume II" to "See Chapter 13"
Page 401
Change “You can also supply other tick marks” to “You can also supply other tick mark labels”
Page 484
Change ”given descriptions” to “given description”
Page 486
Change “returnfalse” to “returnBoolean.FALSE
Page 506 [2]
Change “when it was signed it” to “when it was signed”
Page 535 [2]
Change
appletviewer NotHelloAppletApplication.java
java NotHelloAppletApplication

to

appletviewer AppletApplication.java
java AppletApplication
Page 535
Change
applet = anApplet
Container contentPane = getContentPane();
contentPane.add(applet);

to

applet = anApplet;
add(applet);
Page 545
Change String[] keys to String[] keys()
Page 569 [2]
Change try() to try
Page 569
Change OutputStream to PrintSteam
Page 569 and 570
Change (EmptyStackException s) to (EmptyStackException e)
Page 558
Change “prints that detailed message” to “returns a string containing that detailed message”
Page 608
Change “and chose” to “and choose”
Page 610 [2]
Change setColor(Color.yellow) to setBackground(Color.yellow)
Page 614 [2]
Change
String filename = (String) names.get(0);

to

String filename = (String) files.get(0);
Page 618 [2]
Change “wrong,and” to “wrong, and“
Page 618
Change
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");
Page 618
Change “The error message is: “found: java.lang.Number&java.lang.Comparable<? extends java.lang.Number& java.lang.Comparable<?>>, required: double”. You will learn later in this chapter how to decipher the “found” type declaration.” to “The error message complains, in cryptic terms that vary from one compiler version to another, that there are two ways of interpreting this code, both equally valid.”
Page 623
Change ”Erasure of method” to “Erasure of methods”
Page 624
Change “In the erased type” to “In the DateInterval class”. Change // defined in Pair to // overrides the method defined in Pair to call the first method
Page 626
Change // 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.
Page 628
Change “an array Object[2]” to “an array Comparable[2]
Page 629
Change minmax(T[] a) to minmax(T... a) (2x). Change “is assigned to the String[] variable” to “is cast to Comparable[] as the method returns.”
Page 634
Change “a generic objects” to ”a generic object”
Page 634
Change ”The compiler doesn’t know the exact type of the 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,”
Page 636 [2]
Change “you can call the setObject method” to “you can call the setFirst method”
Page 636 [2]
Change “tests whether a pair contains a given object.” to “tests whether a pair contains a null reference.”
Page 636
Change “turning contains into” to “turning hasNulls into”
Page 646
In the API note for WildCardType, flip the headers • Type[] getLowerBounds() and • Type[] getUpperBounds(), but not the text below. (I.e. getUpperBounds gets the extends bounds.)
Page 637 [2]
Change
PairAlg.swapHelper(result);

to

PairAlg.swap(result);
Page 656/657
In the last line of page 656, change : c to : this. In the second line of page 657, remove the = inreturn = true;
Page 660 [2]
Change “and and then removes” to “and then removes”
Page 671 SetTest.java [2]
Change line 26 to
      for (int i = 1; i <= 20 && iter.hasNext(); i++)
Page 684 [2]
Change
V get(K key)

to

V get(Object key)
Page 684
Change “The key may be null.” to “Implementing classes may forbid null keys.”

Change “The key may be null, but the value must not be null.” to “Implementing classes may forbid null keys or values.”

Page 693
In Figure 13-12, the arrow from Vector to RandomAccess should have a dashed line instead of a solid one.
Page 694
Change "unlike ncopies" to "unlike nCopies".
Page 695
Delete "new " from "new Collections.unmodifiableList(staff)"
Page 702
Change }); to };
Page 705
Change “elements extends the AbstractSequentialList class” to “the element type implements the RandomAccess interface”. Change MenuItem to JMenuItem (6x)
Page 706
Change menu.addItem(item) to menu.add(item) (2x)
Page 707
Change item.getItem(i) to item.getItem(i) and item.getItemCount() to menu.getItemCount().
Page 734
Change "priorites" to "priorities"
Page 751
Change ”you should you should” to ”you should”
Page 717 [2]
Change "the panel is never repainted because the addBall method has completely taken over all processing." to "the panel is only repainted after the addBall method has returned."
Page 725
Change
* @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
Page 727
Remove
public static final int STEPS = 1000;
public static final int DELAY = 3;

from BounceThread.java

Page 730 [2]
Change Thread().currentThread().interrupt() to Thread.currentThread().interrupt()
Page 735
Change getDefaultExceptionHandler to getDefaultUncaughtExceptionHandler
Page 751 [2]
Change “you should you should” to “you should”
Page 755
Change ”call await accounts[from] >= balance” to ”call await accounts[from] >= amount”
Page 758
Change “at least one of the accounts must have more than $1,000” to ”at least one of the accounts must have at least $1,000”
Page 760 [2]
Change “Transfer $997 to from Account 1” to “Transfer $997 from Account 1”
Page 762
Change ”TransferThread” to ”TransferRunnable”
Page 770
Change "unbounded bounded" to "unbounded"
Page 780
Change “connection pool” to “thread pool”
Page 790
Remove line 82 and change 1 to 0 in line 91
Page 793
Change “given maximum number” to “given number”
Page 803
Change "GUI of in" to "GUI in"
Page 810
After “a null reference”, add: (Note that null is actually a literal, not a keyword.)

8th Edition Volume 2 (Java SE 6) ???

Page 7 [3]
In figure 1-3, the arrow from CharBuffer to Reader should instead point to the Readable interface.
Page 10
Change “A buffered input stream reads characters” to “A buffered input stream reads bytes”
Page 11
Change “A buffered output stream collects characters” to “A buffered output stream collects bytes”
Page 22
Change “the static wrap method of the ByteBuffer array” to “the static wrap method of the ByteBuffer class”
Page 54
Change out.write(value); to out.write(original);
Page 64
Change “or null if none exist.” to “or null if this File was not representing a directory.”
Page 74
Change 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”.
Page 80
Change "11;59am" to "11:59am
Page 80
Change the listing caption from RegexTest to RegExTest to match the file name
Page 83 [3]
Change HrefMatch.java Line 33
"<a\\s+href\\s*=\\s*(\"[^\"]*\"|[^\\s>])\\s*>"

to

"<a\\s+href\\s*=\\s*(\"[^\"]*\"|[^\\s>]*)\\s*>"
Page 92
Change &#xD9; to &#xE9;
Page 116
Change
constraints.gridx = Integer.parseInt(value);

to

constraints.gridy = Integer.parseInt(value);
Page 137
Change
<xsd:schema xmlns:xsl="http://www.w3.org/2001/XMLSchema">

to

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
Page 147
Change ”The resulting XML file contains no whitespace” to ”By default, the resulting XML file contains no whitespace”
Page 155
Change “Writers an SVG document of the current drawing.” to “Writes an SVG document of the current drawing.”
Page 160
Remove the third bullet “• A hyphen”
Page 183
Remove source line 45 @param c the counter for the handlers (used in prompts)
Page 184
Change while (in.hasNextLine()) != null) to while (in.hasNextLine() != null)
Page 203
Change String encoding = base64Encode(input); to String encoding = base64Encode(input).trim();

(Apparently, some servers don't like a final \n in the URL encoded string.)

Page 206
Change getAllowsUserInteraction() to getAllowUserInteraction()
Page 207
Change Map<String,List<String>> Map getHeaderFields() to Map<String,List<String>> getHeaderFields()

Change String getContentType to String getContentType()

Page 209
Change “and . - * _ unchanged” to “and . - _ ~ unchanged”
Page 238
Change CREATE TABLE Publisher to CREATE TABLE Publishers
Page 278
Change @Resource("jdbc/corejava") to @Resource(name="jdbc/corejava")
Page 300
Change “Spanish sp” to “Spanish es
Page 305
Line 41 should come after line 37
Page 327
Change “As you saw in Table 5–4” to “As you saw in Table 5–6”
Page 328, 329
Change “Volume I, Chapter 12” to “Chapter 1”
Page 337/338
Line 99 should come after line 96
Page 354
Change event.isAdjusting() to event.getValueIsAdjusting()
Page 366
Remove the line
JLabel label = new JLabel();
Page 393
Change
   else
      setBorder(null);
}
return this;

to

   else
      setBorder(null);
   return this;
}
Page 407
In Figure 6-17, the arrow between DefaultTreeModel and TreeModel should be dotted
Page 437
Remove the paragraph starting “This example concludes our discussion on trees.”
Page 425
Change
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;
Page 487
Change “Volume I, Chapter 12” to “Chapter 1”
Page 529 [3]
Change
skewedAngle = Math.toDegrees(Math.atan2(x * width, y * height));

to

skewedAngle = Math.toDegrees(Math.atan2(-y * height, x * width));
Page 636/7
Remove ”The parameter of the getContents call...retrieve as text”.
Page 658
Change “Next, override the getTransferable method” to “Next, override the createTransferable method”
Page 667
Change “Inthat case, you cannot use local clipboards. Fortunately, you can place” to “You can accomplish this task by placing”
Page 704
Change “The FileNameBean has an indexed extensions property and a constrained filename property” to “The FileNameBean has a filename property and an indexed extensions property
Page 708
Change
IndexedPropertyChangeEvent(Object sourceBean, String propertyName, int index,
Object oldValue, Object newValue)

to

IndexedPropertyChangeEvent(Object sourceBean, String propertyName,
Object oldValue, Object newValue, int index)
Page 710
Change
PropertyDescriptor descriptor = new PropertyDescriptor("fileName", ImageViewerBean.class);

to

PropertyDescriptor descriptor = new PropertyDescriptor("fileName", FilePickerBean.class);
Page 710
Change
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;
   }
}
Page 734
Change “listers” to “listeners”
Page 777
In the CAUTION note, change “in the current directory” to “in the home directory”
Page 792
Change “On Windows, change Unix to NT in both AuthTest.policy and jaas.config” to “On Windows, change UnixPrincpal to NTUserPrincipal in AuthTest.policy and UnixLoginModule to NTLoginModule in jaas.config
Page 840
Change JSEE to JSSE
Page 857
Change “When the local garbage collector finds that there are further local uses” to “When the local garbage collector finds that there are no further local uses”
Page 874/875
Change

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");
Page 882
Remove “In the next chapter, we turn to ...programming language on the same machine.”
Page 886
Change
engine.eval("f.text = ’Ok’");

to

engine.eval("b.text = ’Ok’");
Page 915
Change
@BugReport(reportedBy={"Harry", "Carl"}))

to

@BugReport(reportedBy={"Harry", "Carl"})}) 
Page 919
Change
@Inherited @Persistent { }

to

@Inherited @interface Persistent { }
Page 937
Change “just as you would invoke the Java compiler” to “just as you would start a Java program”
Page 944, 956
Change “Volume I, Chapter 12” to “Chapter 1”
Page 948
The code in Listing 12-10 is jumbled. Lines 22-26 are out of order. The correct sequence of lines is: 25, 26, 22, 23, 24, 27.
Page 950
Change “Here, class is a value that represents a Java object of type Class, 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.