MindView Inc.

Current Active Comments for the 2nd edition of "Thinking in Java"

Remember to press your browser's "refresh" button if you've just added a comment


Comment ID: 1030118-121519-fangzhihua_-sina-_com.cmt
From: fangzhihua
simple chinese Chapter:4
Search for Text: DeathCondition.java

i compile this program and don't get any result.so i corect it:

//: c04:DeathCondition.java
// From 'Thinking in Java, 2nd ed.' by Bruce Eckel
// www.BruceEckel.com. See copyright notice in CopyRight.txt.
// Using finalize() to detect an object that 
// hasn't been properly cleaned up.

class Book {
  boolean checkedOut = false;
  Book(boolean checkOut) { 
    checkedOut = checkOut; 
  }
  void checkIn() {
    checkedOut = false;
  }
  public void finalize() {
    if(checkedOut)
      System.out.println("Error: checked out");
  }
}

public class DeathCondition {
  public static void main(String[] args) {
    Book novel = new Book(true);
    // Proper cleanup:
    novel.checkIn();
    // Drop the reference, forget to clean up:
    new Book(true);
    // Force garbage collection & finalization:
   System.out.println(""); 
    System.gc();
      }
} ///:~

but i don't why .can you tell me? 

Add a comment to this suggestion
Comment ID: 1030118-121434-fangzhihua_-sina-_com.cmt
From: fangzhihua
simple chinese Chapter:4
Search for Text: DeathCondition.java

i compile this program and don't get any result.so i corect it:

//: c04:DeathCondition.java
// From 'Thinking in Java, 2nd ed.' by Bruce Eckel
// www.BruceEckel.com. See copyright notice in CopyRight.txt.
// Using finalize() to detect an object that 
// hasn't been properly cleaned up.

class Book {
  boolean checkedOut = false;
  Book(boolean checkOut) { 
    checkedOut = checkOut; 
  }
  void checkIn() {
    checkedOut = false;
  }
  public void finalize() {
    if(checkedOut)
      System.out.println("Error: checked out");
  }
}

public class DeathCondition {
  public static void main(String[] args) {
    Book novel = new Book(true);
    // Proper cleanup:
    novel.checkIn();
    // Drop the reference, forget to clean up:
    new Book(true);
    // Force garbage collection & finalization:
   System.out.println(""); 
    System.gc();
      }
} ///:~

but i don't why .can you tell me? 

Add a comment to this suggestion
Comment ID: 1030023-084431-imran_javaid_82_-hotmail-_com.cmt
From: imran javaid
2nd edition Chapter:whole book
Search for Text: hardware


i want to programming of hardware aceessing from diffrent lang. that's why i want that you give me the
help about that things

Add a comment to this suggestion
Comment ID: 1021026-194326-id___-hotmail-_com.cmt
From: Ivan Dimov
12 Chapter:14
Search for Text: //: c14:BangBean2.java

A simple Question
p.866
//: c14:BangBean2.java
// You should write your Beans THIS WAY so they 
// can run in a multithreaded environment.
...
  // Notice this isn't synchronized:
  public void notifyListeners() {
    ActionEvent a =
      new ActionEvent(BangBean2.this,
        ActionEvent.ACTION_PERFORMED, null);
    ArrayList lv = null;
    // Make a shallow copy of the List in case 
    // someone adds a listener while we're 
    // calling listeners:
//WHAT IF some1 REMOVES listener while we are calling listeners!!
//THIS IS THE QUESTION of importance here:
    synchronized(this) {
      lv = (ArrayList)actionListeners.clone();
    } //End of SYNC
SLEEP(50000); // suppose some listeners removed here even gc.run() ;-)))
    // Call all the listener methods:
    for(int i = 0; i < lv.size(); i++)
      ((ActionListener)lv.get(i))
        .actionPerformed(a);
  }
Conclusion:

Yes we should write Beans so they can run in a multithreaded environment but THIS IS NOT the way...


From: suresh vora [sureshvora_-hotmail-_com]
i don't know comment

Add a comment to this suggestion
Comment ID: 1021011-074401-sun_-hit-_edu-_cn.cmt
From: Sunner Sun
2nd and 3rd Chapter:8: Interfaces & Inner Classes
Search for Text: c08:Parcel2.java

The last lines you used:

    Parcel2.Contents c = q.cont();
    Parcel2.Destination d = q.to("Borneo");
  }
} ///:~

And you said:


"If you want to make an object of the inner class anywhere except from within a non-static method of
the outer class, you must specify the type of that object as OuterClassName.InnerClassName, as seen in
main( )."

But after deleting "Parcel2.", the code still works.

My jdk version is 1.4.1

Add a comment to this suggestion
Comment ID: 1020931-003141-baric14_-hotmail-_com.cmt
From: antony
1.1.1 Chapter:1
Search for Text: Comments

sorry bout this the comments page did not work so heres my praise:)


Your book is great!!. Im a 13 Year old programmer(really!) and this is fabulous. I've read different
books on java they were to fast (one in perticular)they just spat onu info but your book is great it
takes everything nice and slow explaining everything in depth and complete deatail. The next book i buy
will be thinking in c++ i gurntee it since this is such a good book:)

Add a comment to this suggestion
Comment ID: 1020913-150250-id___-hotmail-_com.cmt
From: Ivan Dimov
12 Chapter:9
Search for Text: ALL THE COUNTRIES of the world and their capitals.


1. I dont know what "Version of Thinking in Java, 2nd edition: : means but my copy says REVISION 12 .
Is it the same???

Thinking in Java 2nd ed. MS Word version:
p.452 near the end of page:

The static rsp, geography, countries, and capitals objects provide prebuilt generators, the last three
using ALL THE COUNTRIES of the world and their capitals. 

ALL THE COUNTRIES ??? I can't see my own coutry there - country with more than 1300 years history?!?


Either correct p.454 - Europe or Easter Europe or at least CHANGE the ABOVE statement "ALL THE COUNTRIES
of the world..." to s.th. more precise like "MOST OF THE CONTRIES"
Please add:
{"BULGARIA","Sofia"}, 
its located at the Black Sea Coast between Turkey, Greece, Romania, Albania and Yugoslavia 

You can see its location here: http://visualroute.visualware.com/ Trace 4: www.dir.bg IP: 194.145.63.12


...and something more: (your comment)

"  This data was found on the Internet, then processed by creating a Python program (see www.Python.org)."


- I don't know who to blame YOU or Python.org or ... you actually didn't reveal real source of this info
but IT'S NOT RELIABLE source.


INTERESTING FACT: I saw that book translated into Bulgarian (...by Soft Press Publishing I think...)
and as it seems even translator didn't check those sources ;-))) ...or ...er.. perhaps this isn't yout
FIRST Letter on the subject?

P.S. I think you should also FIX this CODE:
TIJ2-Word\TIJ-2nd-edition-code\com\bruceeckel\util\CountryCapitals.java

P.P.S. I see same mistake in HTML version of the book: Thinking in Java, 2nd edition, Revision 12


Add a comment to this suggestion
Comment ID: 1020623-192326-tculliton_-profitlogic-_com.cmt
From: Tom Culliton
print Chapter:9, page 432 
Search for Text: and produces a negative value if the argument is less than the current object


The last sentence in the second paragraph describing the return values of Compareable.compareTo conflicts
with the sample code.


"This method takes another Object as an argument, and produces a negative value if the argument is less
than the current object, ..."

The sample code says:

public int compareTo(Object rv) {
  int rvi = ((CompType)rv).i;
  return (i < rvi ? -1 : (i == rvi ? 0 : 1));
}

I believe that the code is correct and the text is wrong.


From: Tom Culliton [tculliton_-profitlogic-_com]
Whoops!  This appears to be fixed in the current electronic version.


Add a comment to this suggestion
Comment ID: 1020603-052607-qindegang_-sina-_com.cmt
From: Qin Degang
PDF Chapter:4
Search for Text: this keyword

In page 204, chapter 4, it mentions that: 
The this keyword-which can be used only inside a method-...
However, the this keyword can also be used in data fields, for example:

public class Test {
	Test t=this;
}

It is compiled successfully.
Thanks.


Add a comment to this suggestion
Comment ID: 1020530-022918-trbhargava_-hotmail-_com.cmt
From: trbhargava
yes Chapter:ALL
Search for Text: ALL

HELLO SIR I read thinking c++ was nice so struggling for java

Add a comment to this suggestion
Comment ID: 1020529-013827-linuxhippy_-web-_de.cmt
From: Clemens Eisserer
latest Chapter:the start-page
Search for Text: link broken


The link for the word-viewers on the start-page is broken. But I think nobody would use that ms-stuff
;-)

Add a comment to this suggestion
Comment ID: 1020430-193050-luigi_-javaextreme-_net.cmt
From: Luigi Viggiano
2nd edition, printed version bought last year Chapter:ch9 Pitfall: the lost exception 
Search for Text: a missing case


Very nice paragraph. But you should also insert the case in which the programmer puts a "return" in the
finally block. The exception in the try {} block is also lost.
example:

try { 
  //...
  anObject.aCodeThatRaiseAnException(); //this throw an Exception 
  //...
} finally {
  return "something"; //here the Exception thrown in the try is lost!!
}

Best regards.
~Luigi Viggiano



Add a comment to this suggestion
Comment ID: 1020427-161155-bret-_b_-usa-_net.cmt
From: Bret Bailey
MS Word Chapter:2
Search for Text: Here is the first Java program again


There is a blank character preceding this initial sentence of the paragraph. I suggest removing it so
that your indentation is consistent.

Add a comment to this suggestion
Comment ID: 1020401-184328-david_-handysoftware-_com.cmt
From: David Handy
9 Chapter:5
Search for Text: You can also do it by inheriting (Chapter 6) from that class.


The footnote on page 265 of the printed version, or footnote [37] of Revision 9 of the HTML version is
entirely wrong and should be removed.


The context of the footnote is a statement saying that making all constructors   private prevents "anyone
but you, inside a static member of the class, from creating an object of that class."


That statement is true, but unfortunately is followed by a footnote reference with the following text:
"You can also do it by inheriting (Chapter 6) from that class." This statement is absolutely false. You
cannot inherit from a class that only has private constructors.
You'll probably want to remove this footnote altogether.

Add a comment to this suggestion
Comment ID: 1020305-212906-pinarkirsentam35_-hotmail-_com.cmt
From: sema
very good Chapter:all
Search for Text: classes and objects

s<eryry

Add a comment to this suggestion
Comment ID: 1020302-182132-doron-_yafe_-bigfoot-_com.cmt
From: Doron Yafe
Revision 12 Chapter:9
Search for Text: c09:Collection1.java


Maybe i miss the point here but in the Collection1.java example appeas the following lines of code:
    .
    .
    .
    // Keep all the elements that are in both
    // c2 and c3 (an intersection of sets):
    c2.retainAll(c3);
    System.out.println(c);
    // Throw away all the elements 
    // in c2 that also appear in c3:
    c2.removeAll(c3);
    System.out.println("c.isEmpty() = " +
      c.isEmpty());
    .
    .
    .


Now... either c2(!) value is printed, <System.out.println(c2)> instead of <System.out.println(c)>,
or (what seems to be the original aim), c(!) value is to be modified <c.retainAll(c3)> instead
of <c2.retainAll(c3)>.

It works just fine the way it is, only it seems to have no point to modify c2(!) if we only print c(!).
The same goes for the second, removeAll, example.


Other than that, Thanx for a great (online) book, i hope it helps me get the right foot into the java
world.


Add a comment to this suggestion
Comment ID: 1020220-021435-wenjinp_-163-_net.cmt
From: pan
2 Chapter:0-19
Search for Text: java

java

Add a comment to this suggestion
Comment ID: 1020219-163927-Thomas_Bolioli_-alumni-_adelphi-_edu.cmt
From: Thomas Bolioli
11 Chapter:7
Search for Text: Diagram on page 321 above "c07:music3:Music3.java"

Chapter 7: Polymorphism page 321 of 11 rev
Tune is missing from the diagram as a member of Instrument.


Add a comment to this suggestion
Comment ID: 1020207-101933-golden-rock_-sohu-_com.cmt
From: John Ren
12 Chapter:2
Search for Text: heap, stack, primitive


Thank you very much for your great TIJ2, which is guiding me to Java World. We are Chinese students,
in our country this book is very popular, we call it classical book of Java and OOP.

Possibly because of the difference of language, we have the following question:


In the section 'Where storage lives' in Chapter 2, about heap we get the information "This is a general-purpose
pool of memory (also in the RAM area) where all Java objects live. "


In the section 'Special case: primitive types' in the same chapter, in the first paragraph there is an
information "That is, instead of creating the variable using new, an "automatic" variable is created
that is not a reference. The variable holds the value, and it's placed on the stack so it's much more
efficient. " 


The question is that if a object has only one data member(field) of a primitive type and the object lives
on the heap, where is that field placed? According to the 2nd information, it should be placed on stack,
but the object is living on the heap.


Beg another help, would you tell us the actual size of the Boolean variable? Some books tell readers
it's 1 bit, otherwise, other books tell us it's 1 byte/8-bit, even there's the third issue: it's 1 int/32-bit.
Which one is right? We're really confused.


Add a comment to this suggestion
Comment ID: 1020201-113422-Thomas_Bolioli_-alumni-_adelphi-_edu.cmt
From: Thomas Bolioli
11 Chapter:4
Search for Text: MultiDimArray Code example


Use curlys when you do your for loops to create explicit blocks. In most cases people can figure out
the implicit blocks and follow but it helps more  to be explicit and in the case of MultiDimArray code
example it makes a world of difference. 
I have inserted an amended copy below.

// Creating multidimensional arrays.
import java.util.*;

public class MultiDimArray {
    static Random rand = new Random();
    static int pRand(int mod) {
        return Math.abs(rand.nextInt()) % mod + 1;
    }
    
    static void prt(String s) {
        System.out.println(s);
    }
    
    public static void main(String[] args) {
        int[][] a1 = {
            { 1, 2, 3, },
            { 4, 5, 6, },
        };
        
        for(int i = 0; i < a1.length; i++){
            for(int j = 0; j < a1[i].length; j++){
                prt("a1[" + i + "][" + j + "] = " + a1[i][j]);
            }
        }
        // 3-D array with fixed length:
        int[][][] a2 = new int[2][2][4];
        for(int i = 0; i < a2.length; i++){
            for(int j = 0; j < a2[i].length; j++){
                for(int k = 0; k < a2[i][j].length; k++){
                    prt("a2[" + i + "][" + j + "][" + k + "] = " + a2[i][j][k]);
                }
            }
        }
        // 3-D array with varied-length vectors:
        int[][][] a3 = new int[pRand(7)][][];
        for(int i = 0; i < a3.length; i++) {
            a3[i] = new int[pRand(5)][];
            for(int j = 0; j < a3[i].length; j++){
                a3[i][j] = new int[pRand(5)];
            }
        }
        for(int i = 0; i < a3.length; i++){
            for(int j = 0; j < a3[i].length; j++){
                for(int k = 0; k < a3[i][j].length; k++){
                    prt("a3[" + i + "][" + j + "][" + k + "] = " + a3[i][j][k]);
                }
            }
        }
        // Array of nonprimitive objects:
        Integer[][] a4 = {
            { new Integer(1), new Integer(2)},
            { new Integer(3), new Integer(4)},
            { new Integer(5), new Integer(6)},
        };
        for(int i = 0; i < a4.length; i++){
            for(int j = 0; j < a4[i].length; j++){
                prt("a4[" + i + "][" + j + "] = " + a4[i][j]);
            }
        }
        
        Integer[][] a5;
        a5 = new Integer[3][];
        for(int i = 0; i < a5.length; i++) {
            a5[i] = new Integer[3];
            for(int j = 0; j < a5[i].length; j++){
                a5[i][j] = new Integer(i*j);
            }
        }
        for(int i = 0; i < a5.length; i++){
            for(int j = 0; j < a5[i].length; j++){
                prt("a5[" + i + "][" + j + "] = " + a5[i][j]);
            }
        }
    }
} ///:~

Add a comment to this suggestion
Comment ID: 1020124-232507-keesan_-world-_std-_com.cmt
From: Morris Keesan
Prentice Hall paperback (6th printing) Chapter:3
Search for Text: If you use it with type byte or short, you don't get the correct values.

If you use it with negative values of type byte or short, you don't get 
the expected results.

(The results are "correct", just not what the novice programmer expects,
and that happens only when the initial values are negative.)

You'll get the "expected" values if you force the values, after the cast
to (int), to have only the bits of the smaller type, using the bitwise & operator described
in the previous section: e.g.

short s = -1;
s = (((int)s) & 0xFFFF) >>> 10;

b = -1;
b = (((int)b) & 0xFF) >>> 10;



Add a comment to this suggestion
Comment ID: 1020124-231720-keesan_-world-_std-_com.cmt
From: Morris Keesan
Prentice Hall paperback (6th printing) Chapter:13
Search for Text: Most of the time you'll just want to let a JScrollPane do it's job

Most of the time you'll just want to let a JScrollPane do its job

Add a comment to this suggestion
Comment ID: 1020114-151044-halt00_-hotmail-_com.cmt
From: Todd Stephan
12 Chapter:9
Search for Text: ", "


In chapter 9 (TIJ2 page ~420), the print function could be more efficient.  There is no need to do the
if check inside the loop.  When there are thousands of items in the array this may make a difference.


        if ( from < to )
            System.out.print(a[from]);
        for (int i=from+1 ; i < to ; i++)
            System.out.print(", " + a[i]);                  


Add a comment to this suggestion
Comment ID: 1020106-105348-rafic_-atl-_fundtech-_com.cmt
From: Rafi Cohen
hard copy as well as the HTML copy Chapter:1, Introducing to objects, the hidden implementation
Search for Text: protected acts like private, with the exception that


According to what I've found about the 'protected' DEFINITIONS in the book, it's accessible only for
'this' as well as for extended classes of 'this'.

However, as you probably know, it also allows access to classes from the same package of 'this', regardless
to the fact of whether they've extended 'this' or not. quoting from "The Java tutorial -Controlling Access
to Members of a Class" (although I'm sure there's no need for that):
"...
Protected

The next access level specifier is protected, which allows the class itself, subclasses (with the caveat
that we referred to earlier), and all classes in the same package to access the members. ...".

I've seen other readers's notes about the levels of access control ORDER as mentioned in the book, but
couldn't find anyone mentioning the CAUSE for the wrong order.
P.S. it's very kind of you to put your books on the WEB. thank you :)

Add a comment to this suggestion
Comment ID: 1020031-164203-mallikarjun-_garipally_-ps-_ge-_com.cmt
From: Mallikarjun
Revision 12 Chapter:13
Search for Text: How to import com.bruceeckel.swing.*

How do i import com.bruceeckel.swing.*

Add a comment to this suggestion
Comment ID: 1020031-082554-lal_swain_-satyam-_com.cmt
From: Lal Swain
It is very good Chapter:Appendix
Search for Text: microsoft and java


I want the electronic version of the book Thinking in Java Ist edition.Can you plz send it accross to
me.

Add a comment to this suggestion
Comment ID: 1020028-220258-cdj-vallejos_-prodigy-_net.cmt
From: Jorge Vallejos
ISBN 0-13-027363-5 Chapter:7
Search for Text: class LivingCreature

The member function finalize() in the class LivingCreature calls a
base class finalize(). Nevertheless, the definition of the class
LivingCreature is not derived from any base class.

The solution seems to be:

Replace:

class LivingCreature {
    ...
}

With:

class LivingCreature extends Characteristic {
    ...
}



Add a comment to this suggestion
Comment ID: 1020021-065710-alex_-tf-_com-_pl.cmt
From: Aleksander Atanassow
12 Chapter:9
Search for Text: ex 13

Dear MR Eckel,

I enjoy very much working through your book TIJ2e. I do each exersize before I turn to 
the next chapter. It's really educating and entertaining. Great work.

    Since you probably have enough of  words of admiration, here is why I write to you:
- in chapter 9 ex13 you ask me to "Fill an array and an  ArrayList with objects of your 
class, using the geography generator". I couldn't do it. geography returns a Pair 
reference. Pair is not for use outside the package. So I wrote my own (based on yours) 
generator method, but it eats me inside "what is it that you had in mind?" How can I use 
the geography in an outside class method?

- the second reason is less important. There is a country in Europe that you omited in 
CountryCapitals.java I happen to be a citizen of it. It's not really my bussiness but maybe 
You missed it incidentaly  and would not mind putting it in. {Bulgaria, Sofia}

Thank you for reading this message. Once again Good Luck with all you do. My next 
stop is Python.

Sincerely

Aleksander.

Add a comment to this suggestion
Comment ID: 1020010-164906-hallorant_-acm-_org.cmt
From: Tim Halloran
paper Chapter:298
Search for Text: Final arguments


Your note that you can still assign a null reference appears to have changed as the following code doesn't
work.  You do get an error about assigning the null to g in the with method.

class Gizmo {
    public void spin() {}
}

public class FinalArguments {
    void with(final Gizmo g) {
        g = null;
    }
    void without(Gizmo g) {
        g = new Gizmo();
        g.spin();
    }
    void f(final int i) {
        // i++
    }
    int g(final int i) {
        return i + 1;
    }
    public static void main(String[] args) {
        FinalArguments bf = new FinalArguments();
        bf.without(null);
        bf.with(null);
    }
}

Add a comment to this suggestion
Comment ID: 1020009-035944-xmh_8088_-sina-_com.cmt
From: fd
d Chapter:ds
Search for Text: df

sdaf

From: turke [alturke_-ayna-_com]
welcom

abo

turke

Add a comment to this suggestion
Comment ID: 1011125-234541-stefan-_zielinski_-ps-_net.cmt
From: Stefan Zielinski
11 Chapter:8
Search for Text: received( )

Replace it with: receiveD( )

Add a comment to this suggestion
Comment ID: 1011108-181748-nunung3_-yahoo-_com.cmt
From: herry wibowo
all Chapter:all
Search for Text: to know about this program and study make a web


i really want have java book because with this book i hope  can make a web  a better before.otherwise,this
program more flexibel in many aplication

Add a comment to this suggestion
Comment ID: 1011022-143039-wefing_-gmx-_de.cmt
From: Stephan Wefing
Revision 12 Chapter:14
Search for Text: public class Sharing2 extends JApplet

hi,

the access to the static variable "accessCount" in class Sharing2 should be synchronized:

  public synchronized static void incrementAccess() {
    accessCount++;
    aCount.setText(Integer.toString(accessCount));
  }

if i run the original code, the output in the text field "Access Count" 
varies wildly and the machine (intel linux 2.4.10, 2xPII, sun sdk 1.3.1) 
starts heavily beeping. The same remark applies to Sharing1.java of the same
chapter.

regards, stephan


Add a comment to this suggestion
Comment ID: 1011022-061010-alex_-etas-_kharkov-_ua.cmt
From: Alexander Pershin
Revision12 Chapter:13
Search for Text: Running applets inside a Web browser


I think IE5(IE6) doesn't support a package name at all. It doesn't depend on a form of tag. Whether you
use <applet> or <object> tag the result will be the same : your IE browser won’t be able
to find applet beginning with
 “package mypackage;
  import javax.swing.*;
  class MyClass extends JApplet{}”

Do not even try to change CLASSPATH environment variable. Or is there anybody knowing this secret? 


Add a comment to this suggestion
Comment ID: 1010827-052122-jani-_latvala_-iki-_fi.cmt
From: Jani Latvala
revision 12 Chapter:11 The Java I/O System
Search for Text: Compression

Hi


You could tell something about this bug ( http://developer.java.sun.com/developer/bugParade/bugs/4244499.html
) when using zip classes.


Add a comment to this suggestion
Comment ID: 1010827-042628-tony_-hcsco-_freeserve-_co-_uk.cmt
From: Tony Hughes
ISBN 0-13-027363-5 Chapter:13
Search for Text: Menus.java


In the menus.java program, the ActionListener ml, presumably intended for the "Open" menu item on the
file menu is never used. THe place where it is intended to be implemented (I think) is shown below.

    for(int i = 0; i < file.length; i++) {
      file[i].addActionListener(ml);   //  changed fl to ml
      f.add(file[i]);


I think you also need to set the action command for the Open menu item, before it will be found in the
ML listener, as below
	
    file[0].setActionCommand("Open");


Add a comment to this suggestion
Comment ID: 1010827-042135-tony_-hcsco-_freeserve-_co-_uk.cmt
From: Tony Hughes
ISBN 0-13-027363-5 Chapter:13
Search for Text: Console.java


In the Console.java program, the commented out version of setDefaultCloseoperation for JDK1.3 is shown
as:

frame.setDefaultCloseOperation(EXIT_ON_CLOSE)

it should actually be

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)

Add a comment to this suggestion
Comment ID: 1010823-102936-alexander_popoff_-hotbox-_ru.cmt
From: Alexander Popoff
11 Chapter:7
Search for Text: Constructors and polymorphism

When describing the order of initialization in
"Order of constructor calls" ("Constructors and polymorphism", Chapter 7),
you implied that the reader must keep in mind the order of class members
initialization, including static ones.

I believe it would be more intelligible to give
a reader an explicit description of initialization:

1. The static members are initialized in the order of declaration.
   This step is repeated recursively such that the static members
   of the root class of the hierarchy are initialized first, followed
   by next-derived class, etc.

2. In the same order, for every class, beginning with the root one, followed
   by next-derived class, etc.:
	a)  The class members are initialized in the order of declaration.
	b)  The class constructor is called.


This order can be illustrated with a slightly modified c07:Sandwich.java example:

//: c07:SandwichModified.java
// Order of constructor calls.

class Meal {
  Meal() { System.out.println("Meal()"); }
  Lettuce ll = new Lettuce(" in Meal");
  static  Lettuce l = new Lettuce(" in Meal, static");
  Cheese c = new Cheese(" in Meal");
  static Cheese cc = new Cheese(" in Meal, static");
  Bread b = new Bread(" in Meal");
  static  Bread bb = new Bread(" in Meal, static");
}

class Bread {
  Bread(String s2) { System.out.println("Bread()" +s2); }
}

class Cheese {
  Cheese(String s3) { System.out.println("Cheese()" +s3); }
}

class Lettuce {
  Lettuce(String s4) { System.out.println("Lettuce()" +s4); }
}

class Lunch extends Meal {
  Lunch() { System.out.println("Lunch()");}
  Lettuce ll = new Lettuce(" in Lunch");
  static  Lettuce l = new Lettuce(" in Lunch, static");
  Cheese c = new Cheese(" in Lunch");
  static Cheese cc = new Cheese(" in Lunch, static");
  Bread b = new Bread(" in Lunch");
  static  Bread bb = new Bread(" in Lunch, static");
}

class PortableLunch extends Lunch {
  PortableLunch() {
    System.out.println("PortableLunch()");
  }
  Lettuce ll = new Lettuce(" in PortableLunch");
  static  Lettuce l = new Lettuce(" in PortableLunch, static");
  Cheese c = new Cheese(" in PortableLunch");
  static Cheese cc = new Cheese(" in PortableLunch, static");
  Bread b = new Bread(" in PortableLunch");
  static  Bread bb = new Bread(" in PortableLunch, static");
}

class SandwichModified extends PortableLunch {
  SandwichModified() { 
    System.out.println("SandwichModified()");
  }
  Lettuce ll = new Lettuce(" in Sandwich");
  static  Lettuce l = new Lettuce(" in Sandwich, static");
  Cheese c = new Cheese(" in Sandwich");
  static Cheese cc = new Cheese(" in Sandwich, static");
  Bread b = new Bread(" in Sandwich");
  static  Bread bb = new Bread(" in Sandwich, static");
  public static void main(String[] args) {
    new SandwichModified();
  }
} ///:~


The output is:

Lettuce() in Meal, static
Cheese() in Meal, static
Bread() in Meal, static
Lettuce() in Lunch, static
Cheese() in Lunch, static
Bread() in Lunch, static
Lettuce() in PortableLunch, static
Cheese() in PortableLunch, static
Bread() in PortableLunch, static
Lettuce() in Sandwich, static
Cheese() in Sandwich, static
Bread() in Sandwich, static
Lettuce() in Meal
Cheese() in Meal
Bread() in Meal
Meal()
Lettuce() in Lunch
Cheese() in Lunch
Bread() in Lunch
Lunch()
Lettuce() in PortableLunch
Cheese() in PortableLunch
Bread() in PortableLunch
PortableLunch()
Lettuce() in Sandwich
Cheese() in Sandwich
Bread() in Sandwich
SandwichModified()


Add a comment to this suggestion
Comment ID: 1010729-002251-wxm_-leedu-_com.cmt
From: wxm
TIJ2code Chapter:TIJ2code
Search for Text: TIJ2code.zip

TIJ2code.zip

Add a comment to this suggestion
Comment ID: 1010725-055544-storm_31_-latinmail-_com.cmt
From: Nilsa
Prentice Hall Chapter:B.Eckel
Search for Text: www.bruceeckel.com

thanks

Add a comment to this suggestion
Comment ID: 1010711-185544-forbesjhb_-prodigy-_net.cmt
From: Jason Forbes
w97 Chapter:8
Search for Text: If you do want extra type safety, you can build a class like this


The main for Month2.java should be placed in a seperate class or the fields should be final.  By placing
it in the same class, the comment about type safety is not completely valid.  The main method works fine:

public static void main(String[] args) {
    Month2 m = Month2.JAN;
    Month2.JAN="ANYTHING";
    System.out.println(m);//prints ANYTHING, not JAN
    m = Month2.number(12);
    System.out.println(m);
    System.out.println(m == Month2.DEC);
    System.out.println(m.equals(Month2.DEC));
  }

Of course, in any real work situations, there would not be any methods like this in the class, but since
it's showing "extra type safety," it should not allow any changes, even internally.

Add a comment to this suggestion
Comment ID: 1010711-013652-niranjan002_-yahoo-_com.cmt
From: niranjan
total Chapter:1-25
Search for Text: java

i  suggest  asu  like



Add a comment to this suggestion
Comment ID: 1010708-180301-jack7777766_-hotmail-_com.cmt
From: Jack Dabah
Revision 12 Chapter:9
Search for Text: com:bruceeckel:util:Arrays2.java


In Arrays2.java the print method might cause slight confusion.  When printing part of an array the start
method will print the range as [a:b]

The confusion is that "a" is the array element as counting from 0, and "b" is the array element as counting
from 1. This is caused because the for loops prints the array elements up to but not including "b". Not
printing b is necessary for the methods that use the array objects length method, since an array of length
5 is actually from 0 to 4. However I suggest "a+1" should be the output instead of "a" so as to confirm
that we are printing array elements counting from 1 not 0, and avoiding confusion on the range of the
print method.

Add a comment to this suggestion
Comment ID: 1010707-085855-Larry_-DefinitiveSolutions-_com.cmt
From: Larry Leonard
paperback? Chapter:15: Distributed Computing
Search for Text: they can vendor independent


Two problems in this sentence.  Correct "EJB's" to "EJBs".  Correct "they can vendor independent" to
"they can be vendor independent".

Wonderful book, BTW, as was TIC++... looking forward to reading "TIDesign Patterns!

Add a comment to this suggestion
Comment ID: 1010707-030750-amolspawar_-hotmail-_com.cmt
From: amol s pawar
2 Chapter:4
Search for Text: projects

please send the projects of the applets .these i have to submitt in my college.

Add a comment to this suggestion
Comment ID: 1010626-124252-rohun2000_-hotmail-_com.cmt
From: rohun
2nd Chapter:ch13
Search for Text: servelets

i net servlets for ur programs where to get them from??????

Add a comment to this suggestion
Comment ID: 1010625-202753-shiwz_-163-_net.cmt
From: shiwz
2 Chapter:all
Search for Text: java

aaa

Add a comment to this suggestion
Comment ID: 1010612-083947-balaji280283_-eth-_net.cmt
From: Balaji
1 Chapter:1
Search for Text: java

ere

Add a comment to this suggestion
Comment ID: 1010610-135108-steitelb_-yahoo-_com.cmt
From: Steve Teitelbaum
revision 12 Chapter:15
Search for Text: There's one other issue when using HttpServlet


It appears that a plausible reason for using doGet in HttpServlet (over using a single generic service
method to handle both GET and POST) is that the http spec states that GET should be safe and idempotent
but POST is not. Thus if invoking service() could produce different side effects for multiple invocations
then technically service() could support POST, but not GET. Hence, one would presumably need to provide
a separate doGet in this case.

Add a comment to this suggestion
Comment ID: 1010609-033825-micael_-pisem-_net.cmt
From: Mikhail Gusarov
printed :) Chapter:15
Search for Text: JPyton

JPython never exists, right name is Jython :)

Add a comment to this suggestion
Comment ID: 1010605-144058-kmadhavan_-hotmail-_com.cmt
From: Madhavan Kasthuri
2 Chapter:6: Reusing Code & Class
Search for Text: There is know way that I know of to make the array handles themselves final

There is no way that I know of to make the array handles themselves final

From: lerabo bogatsu [jbogatsu_-atraxis-_com]

(What do you want me to  do for you ? There is no limit to the text in this box -- please submit entire
code listings if appropriate: )


Add a comment to this suggestion
Comment ID: 1010603-002011-gino-_marckx_-bigfoot-_com.cmt
From: Gino Marckx
11 Chapter:3
Search for Text: Precedence Revisited

In the table describing operator precedence, the unary bitwise operator ~ is not listed.
It should be listed in the first row with the other unary operators.

regards,
Gino.

Add a comment to this suggestion
Comment ID: 1010601-000239-mandgar76_-yahoo-_com.cmt
From: Mahboubeh  Mandegar
2 Chapter:1,2,3,4,5
Search for Text: aplet

please learn easy

Add a comment to this suggestion
Comment ID: 1010527-195940-judel_-kornet-_net.cmt
From: Jeong Jun
1 Chapter:1
Search for Text: 1

111

Add a comment to this suggestion
Comment ID: 1010526-084337-pauloya_-yahoo-_com.cmt
From: Paulo Santos
11 Chapter:15
Search for Text: Along with Jini for local device networks, this chapter has introduced some


The paragraph in the "Summary" section of Chapter 15 that begins with "Along with Jini for local ..."
is accidentally inside an HTML PRE tag.  Therefore, it does not get wrapped and displays as one long
line that goes way beyond the edge of the browser window.


Add a comment to this suggestion
Comment ID: 1010526-084117-pauloya_-yahoo-_com.cmt
From: Paulo Santos
11 Chapter:15
Search for Text: Create and install a security manager that supports RMI

Under the section "Implementing the remote interface" of chapter 15:

The formatting on the HTML version is not well formatted, sentences are cut in the middle and the numbering
of the items is wrong.


Add a comment to this suggestion
Comment ID: 1010526-083905-pauloya_-yahoo-_com.cmt
From: Paulo Santos
11 Chapter:15
Search for Text: as it many span several client requests and pages.

Under the section "Implicit objects" in chapter 15:
"...as it many span several client requests and pages."
I think the word in this phrase should be 'may' and not 'many'.

Add a comment to this suggestion
Comment ID: 1010526-083519-pauloya_-yahoo-_com.cmt
From: Paulo Santos
11 Chapter:15
Search for Text: The leading percent sign may be followed by other characters 


The paragraph in the "Java Server Pages" section of Chapter 15 that begins with "The leading percent..."
is accidentally inside an HTML PRE tag.  Therefore, it does not get wrapped and displays as one long
line that goes way beyond the edge of the browser window.


Add a comment to this suggestion
Comment ID: 1010526-083222-pauloya_-yahoo-_com.cmt
From: Paulo Santos
11 Chapter:13
Search for Text: This chapter was meant only to give you an introduction to the power of Swing 


The paragraph in the "Summary" section of Chapter 13 that begins with "This chapter was meant..." is
accidentally inside an HTML PRE tag.  Therefore, it does not get wrapped and displays as one long line
that goes way beyond the edge of the browser window.


Add a comment to this suggestion
Comment ID: 1010526-083026-pauloya_-yahoo-_com.cmt
From: Paulo Santos
11 Chapter:13
Search for Text: You’ll need to put it into the new (messy, complicated) form shown earlier 


The paragraph in the "Packaging an applet into a JAR file" section of Chapter 13 that begins with "You’ll
need to put it into..." is accidentally inside an HTML PRE tag.  Therefore, it does not get wrapped and
displays as one long line that goes way beyond the edge of the browser window.


Add a comment to this suggestion
Comment ID: 1010526-082610-pauloya_-yahoo-_com.cmt
From: Paulo Santos
11 Chapter:13
Search for Text: Swing contains all the components that you expect to see in a modern UI


The paragraph in the begining of Chapter 13 that begins with "Swing contains all the components..." is
accidentally inside an HTML PRE tag.  Therefore, it does not get wrapped and displays as one long line
that goes way beyond the edge of the browser window.


Add a comment to this suggestion
Comment ID: 1010526-032834-pauloya_-yahoo-_com.cmt
From: Paulo Santos
11 Chapter:13
Search for Text: In general you’ll want to design your classes so that each one does 


The paragraph in the "Separating business logic from UI logic" section of Chapter 13 that begins with
"In general you’ll want to design your classes..." is accidentally inside an HTML PRE tag.  Therefore,
it does not get wrapped and displays as one long line that goes way beyond the edge of the browser window.



Add a comment to this suggestion
Comment ID: 1010526-032709-pauloya_-yahoo-_com.cmt
From: Paulo Santos
11 Chapter:13
Search for Text: Of course, you could also control the two using a listener


The paragraph in the "Sliders and progress bars" section of Chapter 13 that begins with "Of course, you
could also control..." is accidentally inside an HTML PRE tag.  Therefore, it does not get wrapped and
displays as one long line that goes way beyond the edge of the browser window.


Add a comment to this suggestion
Comment ID: 1010526-032530-pauloya_-yahoo-_com.cmt
From: Paulo Santos
11 Chapter:13
Search for Text: The way that this is accomplished in Swing is by cleanly 


The paragraph in the "Capturing an event" section of Chapter 13 that begins with "The way that this is
accomplished..." is accidentally inside an HTML PRE tag.  Therefore, it does not get wrapped and displays
as one long line that goes way beyond the edge of the browser window.


Add a comment to this suggestion
Comment ID: 1010526-032028-pauloya_-yahoo-_com.cmt
From: Paulo Santos
11 Chapter:13
Search for Text: Swing contains all the components that you expect 


The paragraph in the begining of chapter 13 that begins with "Swing contains all the components..." is
accidentally inside an HTML PRE tag.  Therefore, it does not get wrapped and displays as one long line
that goes way beyond the edge of the browser window.


Add a comment to this suggestion
Comment ID: 1010520-052743-lemburg_-aixonix-_de.cmt
From: Christian Lemburg
Revision 12 Chapter:All - Source Code Correction
Search for Text: Makefiles

IMHO, you should change the line "JVC = javac" in your makefiles
to "JVC = javac -g" to make debugging of the source files easier.
This short one-liner did it for me on Linux (standing in the toplevel of the code directory tree):

find . -name 'makefile' | xargs perl -i.bak -pe 's/JVC = javac/JVC = javac -g/'

Also, in chapter 15, there are two DOS-only makefiles where the line
containing the "copy" command (which is not there on linux) has to be
commented out to get a running make:

c15/jsp/makefile
c15/servlets/makefile

From: sgs [fgsfgs_-zdfafdf-_com]
fgsfg

Add a comment to this suggestion
Comment ID: 1010513-113012-jlawrence_-gr-_com.cmt
From: Jeff Lawrence
? Chapter:1 Introduction

Search for Text: You may wonder why, if it’s so beneficial, a singly-rooted hierarchy isn’t it in C++
.


This sentence appears as the first sentence of the last paragraph of the section entitled "The singly-rooted
hierarchy". The word "it" is unnecessary here, "...isn’t it in C++."

Add a comment to this suggestion
Comment ID: 1010513-065804-gheeglyerm_-bol-_com-_br.cmt
From: Guilherme Nogueira
Release 11 Chapter:1

Search for Text: assume that you have had experience in a procedural programming language, although not
necessarily C.

...language, although not necessarily Pascal. (or other procedural language)

I always thought of C being a 'modular' programming language.

Add a comment to this suggestion
Comment ID: 1010506-115057-chris_-gravesnetwork-_com.cmt
From: Chris
revision 11 Chapter:6
Search for Text: Perform the initialization of the blank final inside a method (not the constructor

Text is from question 21.

Is this supposed to be a trick question?  I'm assuming not due to the way the entire question is worded.
 The error then, is that final fields are guaranteed to be initialized by the COMPILER either at the
point of definition, in an initialization section or in all constructors.  You cannot assign a final
variable anywhere else, so it is difficult to demonstrate anything except compiler errors... Am I missing
something?

Add a comment to this suggestion
Comment ID: 1010501-034639-pauloya_-yahoo-_com.cmt
From: Paulo Santos
11 Chapter:11
Search for Text: A “pipe,” which works like a physical


The "Types of InputStream" section has a list of items, the 4th item is not well formatted (on my html
version), so the list restarts to 1 on the next line.
Also on the 4th item the comma is inside the double quote ("pipe,").

Add a comment to this suggestion
Comment ID: 1010431-062643-pauloya_-yahoo-_com.cmt
From: Paulo Santos
11 Chapter:10
Search for Text: When the compiler creates the default constructor, it which automatically 

This phrase doesn't seem correct...
I think the word 'which' shouldn't be there.

Add a comment to this suggestion
Comment ID: 1010429-090942-pauloya_-yahoo-_com.cmt
From: Paulo Santos
11 Chapter:8
Search for Text: This example should move you a long way toward appreciating the value


The paragraph in the "Inner classes & control frameworks" section of Chapter 8 that begins with "This
example should move you..." is accidentally inside an HTML PRE tag.  Therefore, it does not
get wrapped and displays as one long line that goes way beyond the edge of the browser window.


Add a comment to this suggestion
Comment ID: 1010429-033824-nivasss_-usa-_net.cmt
From: B.Nithiyanandan
Revision 11 Chapter:9
Search for Text: Map1.java



In the program Map1.java I would like to point out what may not be a bug but a misleading code in the
program.

In the statements,

public static void test(Map m) {
Collections2.fill(m, geo, 25);
// Map has 'Set' behavior for keys:
Collections2.fill(m, geo.reset(), 25);
...


Obviously,the intention is to fill the Map with the same set of keys twice to show it's Set functionality
for keys.This correctly happens the first time when the method is called for testing HashMap.But when
testing TreeMap you can see that first call to fill the Map follows a geo.reset() and since we dont have
a reset there , the next 25 keys with values are filled.


The result is that when executed ,we have 25 entries for HashMap and nearly double that for TreeMap ,which
is apparently confusing since they are both supposed to follow the Set functionality.

Obviously, the solution is ,

public static void test(Map m) {
Collections2.fill(m, geo.reset(), 25);
// Map has 'Set' behavior for keys:
Collections2.fill(m, geo.reset(), 25);
...


I would also like to point out to a typographical error.In the HTML version

in some chapters - like ch.8 and 9 the sentences just before the end of a section are not wrapped up
and they are also in the same font as that of the code.


Apart form these small errors yours has been an excellent work and i am very much impressed by your conceptual
treatment of not only the language features ,but also the libraries, which i haven't seen in other books.



Add a comment to this suggestion
Comment ID: 1010428-184154-Bruce_-EckelObjects-_com.cmt
From: Bruce Eckel
11 Chapter:1
Search for Text: test

Testing the CGI config

Add a comment to this suggestion
Comment ID: 1010026-132640-gary_-calpc-_org.cmt
From: Gary Benjamin
11 Chapter:TOC
Search for Text: Index


The Index link in both the framed and non-framed version of the table of contents opens the additional
stuff page; and there is no link named "Additional Stuff".

The current html is:

<A HREF="Adstuff.html">Index</A><BR>

In FrameContents.html it should be changed to:

<A HREF="Adstuff.html">Additional stuff</A><BR>
<A HREF="FrameDocIndex.html">Index</A><BR>

and in Contents.html it should be changed to:

<A HREF="Adstuff.html">Additional stuff</A><BR>
<A HREF="DocIndex.html">Index</A><BR>


Add a comment to this suggestion
Comment ID: 1010026-131723-gary_-calpc-_org.cmt
From: Gary Benjamin
11 Chapter:5
Search for Text: Sandwich

In this code example:

//: c05:Lunch.java
// Demonstrates class access specifiers.
// Make a class effectively private
// with private constructors:

class Soup {
  private Soup() {}
  // (1) Allow creation via static method:
  public static Soup makeSoup() {
    return new Soup();
  }
  // (2) Create a static object and
  // return a reference upon request.
  // (The "Singleton" pattern):
  private static Soup ps1 = new Soup();
  public static Soup access() {
    return ps1;
  }
  public void f() {}
}

class Sandwich { // Uses Lunch
  void f() { new Lunch(); }
}

// Only one public class allowed per file:
public class Lunch {
  void test() {
    // Can't do this! Private constructor:
    //! Soup priv1 = new Soup();
    Soup priv2 = Soup.makeSoup();
    Sandwich f1 = new Sandwich();
    Soup.access().f();
  }
} ///:~


I do not think that there is anything incorrect. My comments are mainly about why you chose to include
extra code that does not illustrate the reasons for using a private constructor, nor a mechanism to implement
it. Specifically,

1. I can not figure out what Sandwich illustrates in this context.


2. I can not figure out why you chose to use the same method name f() in Sandwich as in Soup, especially
since it is not used.


3. How can you have "new Lunch()" in the body of Sandwich without either assigning it to a field, as
in:
Lunch meal = new Lunch();
or as a parameter to a method call, as in:
boy.eat(new Lunch);
or as a prefix to calling a method, as in:
new Lunch.test;

Perhaps it is syntactically correct, but an explanation of the circumstances when you would do this would
be helpful.


4. I think the implications of creating a new Sandwich() in Lunch, and a new Lunch in Sandwich() is worthy
of discussion (although off topic for this section on class access).

Add a comment to this suggestion
Comment ID: 1010024-070810-chuck_-ddi-_com.cmt
From: chuck Conlin
Revision 9 Chapter:13
Search for Text: c13

Chapter 13 is missing from the HTML download. 
I downloaded all four zip files,
but there was no Chapter 13.

I went to a 2nd web site:
http://www.perlpeople.com/eckel/

Same problem.

Thank you.

Chuck Conlin

Add a comment to this suggestion
Comment ID: 1010024-001015-oamdg_mb_-yahoo-_com.cmt
From: Milan Babiak
Release 11 Chapter:3. Controlling Program Flow
Search for Text: Precedence revisited

To the table in "Precedence revisited" I would like to add following:

2nd row, 3rd column, Unary operators:
	! boolean complement operator is missing,
	~ bitwise inversion operator is missing,

3rd row, 3rd column, Arithmetic (and shift) operators:
	- the unsigned right shift >>> operator is missing,

4th row, 3rd column, Relational operators:
	- the "instanceof" is missing.

Add a comment to this suggestion
Comment ID: 1010023-083732-michael-_bane_-man-_ac-_uk.cmt
From: Michael Bane
Revision 11 Chapter:04
Search for Text: death condition example

Not sure why but couldn't get you DeathCondition.java example to work.

It doesn't give me "Error: checked out" message at all.  This is on both a Linux box (java version "1.1.7B")
and 
an SGI Origin2000 (java version "1.2.1"; Classic VM (build JDK-1.2.1, 
green threads, mipsjit)

Please advise!

Thanks
MICHAEL


Add a comment to this suggestion
Comment ID: 1010023-083629-michael-_bane_-man-_ac-_uk.cmt
From: Michael Bane
Revision 11 Chapter:04
Search for Text: garbage collector example

Not sure why but even with any of the arguments I couldn't get your 
example Garbage.java to give the same number of finalized and 
created chairs.  This is on both a Linux box (java version "1.1.7B") and 
an SGI Origin2000 (java version "1.2.1"; Classic VM (build JDK-1.2.1, 
green threads, mipsjit)

Please advise!

Thanks
MICHAEL


Add a comment to this suggestion
Comment ID: 1010011-100554-james_jia_-providian-_com.cmt
From: James Jia
Revision 9 Chapter:11, the Java IO System
Search for Text: FileInputStream, FileReader


In the section StreamTokenizer, the FileReader is used to read in a file in the example program SortedWordCount.
However, the text after the example refers to FileInputStream ( which should be FileReader).

public class SortedWordCount {
  private FileReader file;
  private StreamTokenizer st;
  // A TreeMap keeps keys in sorted order:
  private TreeMap counts = new TreeMap();
  SortedWordCount(String filename)
    throws FileNotFoundException {
    try {
      file = new FileReader(filename);
      st = new StreamTokenizer(
        new BufferedReader(file));
      st.ordinaryChar('.');
      st.ordinaryChar('-');
    } catch(FileNotFoundException e) {
      System.out.println(
        "Could not open " + filename);
      throw e;
    }
  }
  

To open the file, a FileInputStream is used, and to turn the file into words a StreamTokenizer is created
from the FileInputStream. 


Add a comment to this suggestion
Comment ID: 1010010-065714-pstein_-mail-_cslf-_org.cmt
From: Peter Stein
Revision 11 Chapter:8
Search for Text: c08:BigEgg2.java


This is a suggestion to improve comprehension on the order in which inner class construction takes place.
 In the BigEgg2 example, even though you explain in text, I still found the two outputs of "Egg2.Yolk()"
confusing.  If I'm not alone, maybe an additional line to the BigEgg2 constructor will clear things up:


  public BigEgg2() { 
  System.out.println("New BigEgg2()");
  insertYolk(new Yolk()); 
  }

This will cause the output to read:

Egg2.Yolk()
New Egg2()
New BigEgg2()
Egg2.Yolk()
BigEgg2.Yolk()
BigEgg2.Yolk.f()

The revised example is included below in its entirety:

//: c08:BigEgg2.java
// Proper inheritance of an inner class.

class Egg2 {
  protected class Yolk {
    public Yolk() {
      System.out.println("Egg2.Yolk()");
    }
    public void f() {
      System.out.println("Egg2.Yolk.f()");
    }
  }
  private Yolk y = new Yolk();
  public Egg2() {
    System.out.println("New Egg2()");
  }
  public void insertYolk(Yolk yy) { y = yy; }
  public void g() { y.f(); }
}

public class BigEgg2 extends Egg2 {
  public class Yolk extends Egg2.Yolk {
    public Yolk() {
      System.out.println("BigEgg2.Yolk()");
    }
    public void f() {
      System.out.println("BigEgg2.Yolk.f()");
    }
  }
  public BigEgg2() { 
  System.out.println("New BigEgg2()");
  insertYolk(new Yolk()); 
  }
  public static void main(String[] args) {
    Egg2 e2 = new BigEgg2();
    e2.g();
  }
} ///:~




.  I was having trouble with the order of constructor

Add a comment to this suggestion
Comment ID: 1010007-041755-songjing_-computer-_org.cmt
From: Song Jing
Revision 9 Chapter:9
Search for Text: //: c09:ArraySize.java

//: c09:ArraySize.java
// Initialization & re-assignment of arrays.

class Weeble {} // A small mythical creature

public class ArraySize {
  public static void main(String[] args) {
    // Arrays of objects:
    Weeble[] a; // Null reference
    Weeble[] b = new Weeble[5]; // Null references
    Weeble[] c = new Weeble[4];
    for(int i = 0; i < c.length; i++)
      c[i] = new Weeble();
    // Aggregate initialization:
    Weeble[] d = { 
      new Weeble(), new Weeble(), new Weeble()
    };

    // Compile error: variable a not initialized:
    //!System.out.println("a.length=" + a.length); 
   
    // Dynamic aggregate initialization:
    a = new Weeble[] {
      new Weeble(), new Weeble()
    };
    System.out.println("a.length = " + a.length);
    System.out.println("b.length = " + b.length);
    // The references inside the array are 
    // automatically initialized to null:
    for(int i = 0; i < b.length; i++)
      System.out.println("b[" + i + "]=" + b[i]);
    System.out.println("c.length = " + c.length);
    System.out.println("d.length = " + d.length);
    a = d;
    System.out.println("a.length = " + a.length);

    // Arrays of primitives:
    int[] e; // Null reference
    int[] f = new int[5];
    int[] g = new int[4];
    for(int i = 0; i < g.length; i++)
      g[i] = i*i;
    int[] h = { 11, 47, 93 };
    // Compile error: variable e not initialized:
    //!System.out.println("e.length=" + e.length);
    System.out.println("f.length = " + f.length);
    // The primitives inside the array are
    // automatically initialized to zero:
    for(int i = 0; i < f.length; i++)
      System.out.println("f[" + i + "]=" + f[i]);
    System.out.println("g.length = " + g.length);
    System.out.println("h.length = " + h.length);
    e = h;
    System.out.println("e.length = " + e.length);
    e = new int[] { 1, 2 };
    System.out.println("e.length = " + e.length);
  }
} ///:~
Here’s the output from the program:

a.length = 2
b.length = 5
b[0]=null
b[1]=null
b[2]=null
b[3]=null
b[4]=null
c.length = 4
d.length = 3
a.length = 3
f.length = 5
f[0]=0
f[1]=0
f[2]=0
f[3]=0
f[4]=0
g.length = 4
h.length = 3
e.length = 3
e.length = 2


From: Charlie Guttenberg [charles-_guttenberg_-med-_ge-_com]
When I compile and run this example (unchanged from the downloaded
version), I get the following output (note that a.length = 3 both times):

b.length = 5
b[0]=null
b[1]=null
b[2]=null
b[3]=null
b[4]=null
c.length = 4
d.length = 3
a.length = 3
a.length = 3
f.length = 5
f[0]=0
f[1]=0
f[2]=0
f[3]=0
f[4]=0
g.length = 4
h.length = 3
e.length = 3
e.length = 2


Add a comment to this suggestion
Comment ID: 1010002-091314-bcowen_-osmotic-_com.cmt
From: Bradley Cowen
Revision 11 Chapter:9
Search for Text: fill an array, then to produces values

line should read:

fill an array, then to produce [instead of produces] values

Add a comment to this suggestion
Comment ID: 1001131-150916-shilkrot_-brown-_edu.cmt
From: Leonid Shilkrot
Hard copy Chapter:Source code from this web page
Search for Text: makefiles


The makefiles that you include with the source code are written in DOS. I'm using LInux, and my make


produces an error because of the DOS's \r character at the end of each line.  If you remove these \r's,

make works fine.  Just in case, I'm using this version of make:

[shilkrot@en737l c04]$ make -v
GNU Make version 3.77, by Richard Stallman and Roland McGrath.


Leo.


Add a comment to this suggestion
Comment ID: 1001131-140449-ericlee_-sympatico-_ca.cmt
From: Eric Lee
printed, PDF Rel. 11 Chapter:13
Search for Text: not like the combo box in Windows

On p. 751:

"Java’s JComboBox box is not like the combo box in Windows, which lets
you select from a list or type in your own selection. With a JComboBox
box you choose one and only one element from the list."

JComboBox is in fact editable (type in or edit a selection) if:

JComboBox c = new JComboBox();
// ...
c.setEditable(true);   // defaults to false

The editable item defaults to [0] if there is one and is replaced by the chosen item.
It is referred to as [-1] if it has been edited before being chosen or there was no [0].


Add a comment to this suggestion
Comment ID: 1001129-140503-erikbuljan_-email-_com.cmt
From: Erik Buljan
book Chapter:3
Search for Text: test2


Exercise 3 in Chapter 3 mentions the method "test2()" to be found in either the "if-else" or "return"
sections.  There is no test2() in either of these sections.  There are two test1()'s, and they are identical
.

Add a comment to this suggestion
Comment ID: 1001128-083340-pstein_-mail-_cslf-_org.cmt
From: Peter Stein
11 Chapter:6
Search for Text: // Cannot be compile-time constants


The source code example c06:FinalData.java contains a comment that needs to be corrected.  The comment


     // Cannot be compile-time constants

should be changed to

     // Does not have to be compile-time constants

                  or

     // Value determined at run-time


Add a comment to this suggestion
Comment ID: 1001122-144937-chiarettir_-libero-_it.cmt
From: Roberto Chiaretti
Prentice-Hall published edition Chapter:11: The Java I/O System
Search for Text: Decorator classes FilterInputStream and FilterOutputStream



The FilterInputStream and FilterOutputStream classes are supposed to be abstract all over the chapter,
while they are reported as 'regular' public classes in the JDK 1.3 on line documentation.

Add a comment to this suggestion
Comment ID: 1001120-051907-yt16613_-glaxowellcome-_com.cmt
From: Ryan Tang
Revision 9 Chapter:13
Search for Text: entire chapter 13 is missing

chapter13.html file is missing from download and installation.


Not sure if the following errors are related to the above sympton, I got two errors during the unzip
process (no error during the download, though):

1. tij-2ndEdition-code2.zip
   Bad CRC 2194b097 (should be 5319e439)

2. tij-2ndEdition-html
   bad CRCb06f62cd (should be da9eba54)

Thanks.

Ryan Tang

Add a comment to this suggestion
Comment ID: 1001119-214620-jingjinyu_-hotmail-_com.cmt
From: Jingjin Yu
Current Chapter:15
Search for Text: localhost does not work with RMI


Actually, it does work. I've successfully run the ComputePi example from sun's website. I've tried both
machine name and localhost, both work fine. I've also tried JDK1.2.2 and JDK1.3.

Add a comment to this suggestion
Comment ID: 1001119-065613-tangtony_-hotmail-_com.cmt
From: Tony Tang
revision 11 Chapter:13
Search for Text: Menus.java

Sorry, the following post should be posted to correction instead of comment.

In chapter 13, sample program Menus.java, there are two typos in the fuction  public void init(){}

The first typo:
   Error
      ......
      ......
      safety[1].setActionCommand("Hide");
 ===> safety[0].setMnemonic(KeyEvent.VK_H);
      safety[1].addItemListener(cmil);
   Correct
      ......
      ......
      safety[1].setActionCommand("Hide");
 ===> safety[1].setMnemonic(KeyEvent.VK_H);
      safety[1].addItemListener(cmil);

The second typo:    
   Error
      ......
      ......
      for(int i = 0; i < file.length; i++) {
 ===>   file[i].addActionListener(fl);
        f.add(file[i]);
      }
   Correct
      ......
      ......
      for(int i = 0; i < file.length; i++) {
 ===>   file[i].addActionListener(ml);
        f.add(file[i]);
      }



Even with those two typos, the program can still be compiled and run. But it just doesn't run correctly.



Keep the good work.
Tony Tang


Add a comment to this suggestion
Comment ID: 1001114-160034-car_door_-hotmail-_com.cmt
From: Josh Adams
1 Chapter:13
Search for Text: A display framework


In Console.java, you perform extra work to get the name of the class. Consider this excerpt from the
source:

String t = o.getClass().toString();
// Remove the word "class":
if (t.indexOf("class") != -1)
  t = t.substring(6);

The following code is much more concise:

String t = o.getClass().getName();

Add a comment to this suggestion
Comment ID: 1001114-050348-angelarnal_-worldonline-_es.cmt
From: Angel Arnal
Rev. 11 Chapter:2
Search for Text: It's only a syntactic difference

It's only a semantic difference

From: Morris Keesan [keesan_-world-_std-_com]
It's neither a syntactic nor semantic difference.  It's a terminology or vocabulary difference.
"Function" and "method", as used, are semantically and syntactically identical.


From: ppp [p_-uiu-_es]
dfw45rwre wrtwr rwr

Add a comment to this suggestion
Comment ID: 1001111-175225-rod_-fast-_fujitsu-_com-_au.cmt
From: Rod Lee
Revision 11 Chapter:3
Search for Text: Auto increment and decrement


Your explanation of the workings of the prefix and postfix operators is back to front.  The actual timing
of the associated operation and the updating of the variable's value is probably obvious to people studying
the output of the example, though.  Your explanation following the sample output is also (consistently,
at least) incorrect.

I appreciate your efforts with the book very much.  Thank you.

Add a comment to this suggestion
Comment ID: 1001111-045530-dieter-_noack_-bam-_de.cmt
From: Dieter Noack
Rev. 11 Chapter:Example
Search for Text: CopyConstructor.java

In the example CopyConstructor.java a NullPointerException is thrown

Exception in thread "main" java.lang.NullPointerException
        at Fruit.<init>(CopyConstructor.java:55)
        at Tomato.<init>(CopyConstructor.java:73)
        at CopyConstructor.ripen(CopyConstructor.java:109)
        at CopyConstructor.main(CopyConstructor.java:120)


This is because the creation of the array Seed[] s in the constructor of class Fruit is outside the scope
of the copy-constructor in Fruit. I suppose the statement s = f.s; should be inserted.

...
class Fruit {
  private FruitQualities fq;
  private int seeds;
  private Seed[] s;
  Fruit(FruitQualities q, int seedCount) { 
    fq = q;
    seeds = seedCount;
    s = new Seed[seeds];
    for(int i = 0; i < seeds; i++)
      s[i] = new Seed();
  }
  // Other constructors:
  // ...
  // Copy constructor:
  Fruit(Fruit f) {
    fq = new FruitQualities(f.fq);
    seeds = f.seeds;
    s = f.s; // insert this statement to avoid NullPointerException
    // Call all Seed copy-constructors:
    for(int i = 0; i < seeds; i++)
      s[i] = new Seed(f.s[i]);
    // Other copy-construction activities...

BTW.: Your book is great and I enjoy reading it.

From: Bill Love [blove_-allstate-_com]

Inserting "s = f.s" is not quite correct, as it misses the point of the copy constructor idea, since
we want to copy the data, not the reference.

It's necessary to create a new Seed array with "s = new Seed[seeds]", as in the other constructor.

Add a comment to this suggestion
Comment ID: 1001106-153336-frank-_kruchio_-paradise-_net-_nz.cmt
From: Frank Kruchio
Version 11, 2nd edition Chapter:Chaper 08
Search for Text: InterfaceCollision.java 

In the InterfaceCollision.java

Inside class C2 and C3 comments say next to:

public int f(int i) { return 1; }  // overloaded

They are not overloaded, both are just implementation of the interface methods.


Also something might worth mentioning.
At the very beginning of Chapter 08 Eckel says,

"C++, for example does not contain such mechanisms, ..."

referring to interfaces and inner classes.

There are Nested classes in C++, may be worth mentioning.

Add a comment to this suggestion
Comment ID: 1001030-015454-estelag_-arrakis-_es.cmt
From: Estela González
any Chapter:homepage
Search for Text: translation


In "electronic translations", (http://www.bruceeckel.com/TIJ2/index.html), it should say "portuguese"
instead of "portugese".

Add a comment to this suggestion
Comment ID: 1001029-203735-rmtwede_-gotoworld-_com.cmt
From: Randall Twede
11 Chapter:13
Search for Text: Applet default layout

you state:


"The normal behavior of an applet is to use the BorderLayout, but that won’t work here because (as you
will learn later in this chapter when controlling the layout of a form is examined in more detail) it
defaults to covering each control entirely with every new one that is added. However, FlowLayout causes
the controls to flow evenly onto the form, left to right and top to bottom."

then later:


"The applet uses a default layout scheme: the BorderLayout (a number of the previous example have changed
the layout manager to FlowLayout). Without any other instruction, this takes whatever you add( ) to it
and places it in the center, stretching the object all the way out to the edges."

the default layout of Applet is FlowLayout not BorderLayout! 

From: Frank Kruchio [frank-_kruchio_-paradise-_net-_nz]
The default layout manager for an Applet is FlowLayout
on the other hand for JApplet (in JFC, Swing) it is BorderLayout.


Add a comment to this suggestion
Comment ID: 1001029-202040-rmtwede_-gotoworld-_com.cmt
From: Randall Twede
11 Chapter:14
Search for Text: stop() method


"The reason that the stop( ) method is deprecated is because it doesn’t release the locks that the thread
has acquired, and if the objects are in an inconsistent state (“damaged”) other threads can view and
modify them in that state." 

if the thread doesn't release the locks, how can any other thread view the object?

it cannot! the thread releases all locks when stop() is called!

Add a comment to this suggestion
Comment ID: 1001029-175858-frank-_kruchio_-paradise-_net-_nz.cmt
From: Frank Kruchio
Version 11, 2nd edition Chapter:5
Search for Text: Now this package name can be used as an umbrella name space for the


A small error. In the creating unique package names section in chapter 5 inside the Vector class you
print: com.bruceeckel.util.Vector;

It should be:
System.out.println("com.bruceeckel.simple.Vector");

same error in the List class where it should be

System.out.println("com.bruceeckel.simple.List");




It's worth mentioning that when the Java interpreter will search the CLASSPATH defined directories in
order and will find a class name like "List" for example what Eckel defined, then it will try to use
that.

And you get an error in this case
[frank@babe Chapter_04]$ javac LibTest.java
LibTest.java:8: List is abstract; cannot be instantiated
        List l   = new List();
                   ^           
This is because Java found the built in java utility class first and not yours.
If you change the order of the directories in the CLASSPATH or
you fully define the object at creation as:

com.bruceeckel.simple.List l = new com.bruceeckel.simple.List();

it will work.
Another option to import them individually as:

import com.bruceeckel.simple.Vector;
import com.bruceeckel.simple.List;

Add a comment to this suggestion
Comment ID: 1001029-144144-bill_-truewill-_net.cmt
From: Bill Sorensen
the physical book Chapter:11
Search for Text: Multifile storage with Zip


In c11:ZipCompress.java, there are several pieces of code similar to "while((c = in.read() != -1) out.write(c)".
 In testing, I found that zipping was unacceptably slow on large files.  When I switched to doing my
own buffering (reading and writing a byte array), I saw an order of magnitude speed increase, even with
buffered streams.  It appears that the overhead of all those read/write method calls is significant.
You might consider changing the code to reflect this, as many people will base their code on yours.

Add a comment to this suggestion
Comment ID: 1001028-063311-nick-_hudson_-compaq-_com.cmt
From: nick hudson
11 Chapter:13
Search for Text: TextFields.java

In this example program, you have the line:

  DocumentListener dl = new T1();


I don't think this line is necessary - the variable "dl" is not subsequently used at all, and you already
created a T1 a couple of lines earlier where you had:

  ucd.addDocumentListener(new T1());


The program doesn't seem to behave any differently if the "dl" declaration is removed; maybe I'm missing
something subtle but I can't see that it is doing anything useful...

regards




Add a comment to this suggestion
Comment ID: 1001024-194726-frank-_kruchio_-paradise-_net-_nz.cmt
From: Frank Kruchio
Version 11, 2nd edition Chapter:3
Search for Text: ListCharacters.java program

Just a question about the ListCharacters.java program.

value: 25 character:
value: 26 character: ?
value: 27 character:
alue: 28 character:
value: 29 character:
value: 30 character:

This is part of the output, on Red Hat Linux 7.0, using 
glibc-2.1.94-3 and SDK v1.3. Compiled with javac.

It seems to print character number 26 without clearing the screen.



Add a comment to this suggestion
Comment ID: 1001024-191446-frank-_kruchio_-paradise-_net-_nz.cmt
From: Frank Kruchio
Version 11, 2nd edition Chapter:3
Search for Text: The conditional expression for the while says "keep doing this loop

In WhileTest.java explanation

The conditional expression for the while says "keep doing this loop until 
the number is greater."

Probably you meant to say:

The conditional expression for the while says "keep doing this loop until 
the number is SMALLER."

Number is r and the expression says(r < 0.99d)




Add a comment to this suggestion
Comment ID: 1001024-021024-frank-_kruchio_-paradise-_net-_nz.cmt
From: Frank Kruchio
Version 11, 2nd edition Chapter:3
Search for Text: while, do-while and for control looping and are

The very first line under the iteration subsection:

while, do-while and for control looping and are sometimes classified

Probably you meant:

while, do-while and for control looping are sometimes classified

Add a comment to this suggestion
Comment ID: 1001024-012159-frank-_kruchio_-paradise-_net-_nz.cmt
From: Frank Kruchio
version 11, 2nd edition Chapter:3
Search for Text: c03:IfElse2.java

In the IfElse2.java program.

Just an idea.
I would remove the
int result = 0;

to avoid confusion. It is not used for anything just declared, so redundant anyway.

Add a comment to this suggestion
Comment ID: 1001023-221050-frank-_kruchio_-paradise-_net-_nz.cmt
From: Frank Kruchio
Version 11, 2nd edition Chapter:Chapter 3
Search for Text: there's no ambiguity, so an L after the 200 would be superfluous.

Small correction only. Below the line you find the following code fragment:

float f4 = 1e-47f;               // 10 to the power

The compiler issues the following error message if you add this line 
to any program:

floating point number too small
        float f4 = 1e-47f;               // 10 to the power 
                  ^

From: Sheng-Ying Hsiao [wawo_-ethome-_net-_tw]
The code frament may be:

float f4 = 1e-47f;               // 10 to the power

Then the compiler issues the following error message:

possible loss of precision
found   : double
required: float
		float f=1e-47;
                        ^



Add a comment to this suggestion
Comment ID: 1001023-074954-nwebre_-post-_harvard-_edu.cmt
From: Neil Webre
Revision 9 Chapter:15
Search for Text: final int maxthreads

The sentence 

"The maximum number of threads allowed is determined by the final int maxthreads."


is misleading, and also not in conformance with the code for class MultiJabberClient. It leads one to
think that maxthreads (actually MAX_THREADS) is the number of threads to be generated by the client.
A careful reading of the code clears it up, but I suggest the sentence be changed to read


"The maximum number of threads allowed to exist simultaneously is determined by final int MAX_THREADS
in class MultiJabberClient."

Add a comment to this suggestion
Comment ID: 1001022-231114-oamdg_mb_-yahoo-_com.cmt
From: Milan Babiak
Release 11, ISBN 0-13-027363-5, To be published by Prentice-Hall mid-June, 2000 Chapter:Index
Search for Text: inizialization

Small typing error on the page 1107
Instead "inizialization: lazy · 273" should be "initialization: lazy · 273"

Add a comment to this suggestion
Comment ID: 1001022-082107-nick-_hudson_-compaq-_com.cmt
From: Nick Hudson
11 Chapter:13
Search for Text: BorderLayout


In your description for BorderLayout, you say that when you're adding an object to a panel, "you can
use the overloaded add() method that takes a constant value as its first argument".  In the subsequent
example, "BorderLayout1" you have code of the form:

Container cp = getContentPane();
cp.add(BorderLayout.NORTH,
  new JButton("North"));
.
.

I think the method you're picking up by doing this is
"Container.add(String name, Component comp)".  In the Sun JAVA docs it

says "It is strongly advised to use the 1.1 method, add(Component, Object) in place of this method."


In fact I think that for your example you should be using 
"Container.add(Component comp, Object constraints)", which would make your
code look like this instead:

Container cp = getContentPane();
cp.add(new JButton("North"),
  BorderLayout.NORTH);
.
.

i.e. the arguments are the other way round.  If you look at the API docs
for "BorderLayout", you'll see they have some example code which does

it this way (or at least there's a comment there which shows it being done this way) - it has the following
line of code:

p2.add(new TextArea()); // same as p.add(new TextArea(), BorderLayout.CENTER);

Incidentally, as I type that I can see that there's a typo in the Sun docs,
where they have "p.add" instead of "p2.add" in the comment but I think my point is still valid...

Regards




Add a comment to this suggestion
Comment ID: 1001021-091332-Marc-Etienne-_Vargenau_-alcatel-_fr.cmt
From: Marc-Etienne Vargenau
11 Chapter:9
Search for Text: DJIBOUTI

Errors in the capitals list:

The capital of DJIBOUTI is Djibouti (of course), not Dijibouti
CETE D'IVOIR should be CÔTE D'IVOIRE (O with circumflex)
The funny ones are:
1) the capital of GUINEA-BISSAU is Bissau
instead of capital of GUINEA is "-" and the capital of BISSAU is Bissau
2) the capital of BOSNIA-HERZEGOVINA is Sarajevo.
The last two show (as explained in the note) that the text was 
processed automatically.

Add a comment to this suggestion
Comment ID: 1001017-092819-khall_-talient-_com.cmt
From: Kurt Hall
Revision 11 Chapter:10
Search for Text: Rethrowing an exception


You could mention that a try block does not need a catch block.  I'm not sure how often I would use this
myself since it may be helpful to keep the catch block simply for documentation or a placeholder for
future exception handling, but there are quite a few instances in our own code where we catch and simply
rethrow an exception.  A common example is when the main reason we have a try block is because we need
a finally block to free some resource.

try {
   sw.on();     // throws exception
}
finally {
   sw.off();
}

Add a comment to this suggestion
Comment ID: 1001017-092309-khall_-talient-_com.cmt
From: Kurt Hall
Revision 11 Chapter:10
Search for Text: Pitfall: the lost exception


At least with Solaris java (Solaris VM (build Solaris_JDK_1.2.1_02, native threads, sunwjit)), I am able
to ignore the HoHumException and allow the VeryImportantException to continue unimpeded.  I don't know
if this is due to the compiler or the intent of the Java spec.

Instead of:

    try {
      lm.f();
    } finally {
      lm.dispose();
    }

Do the following:

    try {
      lm.f();
    } finally {
      try {lm.dispose();} catch( HoHumException} {;}
    }

The output is:
Exception in thread "main" A very important exception!
        at java.lang.Throwable.fillInStackTrace(Native Method)
        at java.lang.Throwable.<init>(Throwable.java:82)
        at java.lang.Exception.<init>(Exception.java:33)
        at customerService.test.VeryImportantException.<init>(TestExceptions.java:8)
        at customerService.test.TestExceptions.f(TestExceptions.java:22)
        at customerService.test.TestExceptions.main(TestExceptions.java:31)


Add a comment to this suggestion
Comment ID: 1001015-182907-amitchell_-optusnet-_com-_au.cmt
From: Andrew Mitchell
Revision 11 Chapter:8: Interfaces & Inner Classes
Search for Text: (since protected also gives package access—that is, protected is also “friendly”)

Sentence should read:

PDestination is protected, so no one but the Parcel3 class, its inner classes, and its 
inheritors can access it.

Explanation:

Protected access is not friendly!

Java seems to be consistent with the C++ definition of protected which is 
basically that protected is the same as private, except the inheritor can still have
access.

For example, here's a new listing for the Test package:

  class Test {
    public static void main(String[] args) {
      Parcel3 p = new Parcel3();
      Contents c = p.cont();
      Destination d = p.dest("Tanzania");
      
      // Illegal -- PDestination is protected!  Only Parcel3 and
      // its inheritors can access PDestination!
      //!PDestination pd2 = new PDestination("Australia");

      // Illegal -- can't access private class:
      //! Parcel3.PContents pc = p.new PContents();
    }
  } ///:~

The line attempting to create Australia does not compile as PDestination cannot
be used outside Parcel3 (even though Test is in the same package as Parcel3 as stated
in the text).

Going further, it appears to me that the Java language is inconsistent 
with the use of the Private keyword in inner classes.  In the Parcel3 example, I would have 
thought that not even the Parcel3 class would be able to create a PDestination instance
since its constructor is declared private.  Java is inconsistent here.  If PDestination
was a standalone class, no-one would be able to create that class.  Parcel3 should not
get special treatment just because the PDestination class is an inner class.  The rules for
private constructors should be consistent.  In fact, the inheritors of Parcel3 do not
get special treatment - they can't create a PDestination, even though its declared protected
in Parcel3!  

A minor issue, as its only a class and its inner classes which have this
feature, but is seems inconsistent to me.

From: Andrew Mitchell [amitchell_-optusnet-_com-_au]
Ok, I'm wrong, protected *is* friendly.  But I still can't believe it!

In the example above the 'privateness' comes from that of the constructor, not the
protected keyword.  As an ex C++ and Ada programmer, I can't understand the reason
behind making the protected keyword the same as 'friendly'.  This seems very dodgy to
me.

My comment regarding the strange nature of the private constructor in the example in
the text still stands, but there no mistake in the text per se.

Andrew

Add a comment to this suggestion
Comment ID: 1001003-033001-verhagent_-logica-_com.cmt
From: Tjeerd Verhagen
release 11 Chapter:11, page 575
Search for Text: method to the list( )

The text'method to the list( )' was inserted twice, where it should be only once.

paragraph:
----------
It says all that this type of object does is provide a method called
accept( ). The whole reason behind the creation of this class is to provide
the accept( ) method to the list( ) method so that list( ) can “call back”
accept( ) to determine which file names should be included in the list.
----------


Add a comment to this suggestion
Comment ID: 1001003-023924-hamer_-csd-_uu-_se.cmt
From: John Hamer
Revision 10 Chapter:A
Search for Text: The copy-constructor


This whole section is a red herring.  The code doesn't "work" in Java, and the code doesn't "work" in
C++.  In both languages, a call to new Tomato(t) will return a Tomato.  And so it should; that's what
the programmer asked for.

Your explanation of "Why does it work in C++ and not Java"? is gobbledygook.  I suggest you remove it.



Add a comment to this suggestion
Comment ID: 1000931-224225-E-_S-_Brinkman_-zonnet-_nl.cmt
From: Emile Brinkman
Revision 11 Chapter:1
Search for Text: -


In the last alinea of the sub-paragraph "Java" in the paragraph "Client-side programming" you wrote:



"If you’re a Visual Basic programmer, moving to VBScript will be your fastest solution, and since
it will probably solve most typical client/server problems you might be hard pressed to justify learning
Java."


This is a dangerous statement! I think you must note that VBScript as a client-side scripting language
is only supported in Microsoft Internet Explorer. JavaScript (or JScript in IE) is the standard for client-side
programming.

As for server-side programming VBscript is a popular solution because it the most chosen scripting language
in ASP.

I have another remark.
You wrote in the sub-paragraph "Scripting languages" of the same paragraph:


"The most commonly discussed browser scripting languages are JavaScript (which has nothing to do with
Java; it’s named that way just to grab some of Java’s marketing momentum)"


Before I began programming in Java I've programmed in JavaScript. I think you are giving here a wrong
impression. The syntax of the languages is very similar in my opinion (and I should know). I'm convinced
that it helped me quite a bit when learning Java. 


Moreover Java applets and JavaScript can communicate with each other. You can call Java methods and variables
from JavaScript and vice versa. So the bond between the two languages is stronger than most people believe.




Don't get the wrong idea because of my critics. My compliments for your cristal clear explanations and
keep up the good work!

Add a comment to this suggestion
Comment ID: 1000930-063654-Douglas_-McKirahan-_com.cmt
From: Douglas McKirahan
Revision 11 Chapter:5
Search for Text: "Access specifiers in Java give valuable control "


The following paragraph appears in the Summary of Chapter 5 "Hiding the Implementation".  The words do
not wrap as a <PRE> tag is used; specifically, "<BLOCKQUOTE><FONT SIZE = "+1"><PRE>".



"Access specifiers in Java give valuable control to the creator of a class. The users of the class can
clearly see exactly what they can use and what to ignore. More important, though, is the ability to ensure
that no user becomes dependent on any part of the underlying implementation of a class. If you know this
as the creator of the class, you can change the underlying implementation with the knowledge that no
client programmer will be affected by the changes because they can’t access that part of the class."

Add a comment to this suggestion
Comment ID: 1000929-014158-Douglas_-McKirahan-_com.cmt
From: Douglas McKirahan
Revision 11 Chapter:13
Search for Text: n/a

The download contains 
"TIJ-2nd-edition-code-1.zip" and TIJ-2nd-edition-code-2.zip";
they both contain a "c13" folder with different contents.

Also, in Chapter 2, the "c02" in the line
"Move to subdirectory c02 and type:"
looks like "co2" when viewed;
(in Netscape 4.76 under Windows 98).

Add a comment to this suggestion
Comment ID: 1000926-060911-rothgi_-nswccd-_navy-_mil.cmt
From: Gary Roth
Print Edition Chapter:9
Search for Text: then to produces values to search for:

Minor grammar mistake.  Should be "then to produce values to search for:"


(Technically, you also can't use for to end a sentence, but changing that would cause an akward construction.
)

Add a comment to this suggestion
Comment ID: 1000923-230824-gerhard-_eymann_-dwd-_de.cmt
From: G. Eymann
Rev. 3 Chapter:Appendix A
Search for Text: JNI, Passing and Using Java Objects in/from C


The listing of the C source file UseObjImpl.c on page 953 has errors, it should be: (*env)->Get...
rather than: env->Get... etc. The previous example on page 950 is correct. 


The example does not run (JDK 1.3.0-C, Windows NT). CallVoidMethod produces an HotSpot VM error (EXCEPTION_ACCESS_VIOLATION,
without HotSpot it doesn't run either). According to Sun's bug parade, an error with the given ID has
already been reported.


From: G. Eymann [gerhard-_eymann_-dwd-_de]

My first remark on the syntax is not correct, the syntax in the book is OK. With Visual Studio "cl" command
line compiler, the file extension must be cpp, not c. Sorry for that. 
The reported error still occurs. 

Add a comment to this suggestion
Comment ID: 1000921-123851-geldin_-mac-_com.cmt
From: Jeremy Sherman
Revision 11 Chapter:Introduction
Search for Text: and complained of me mumbling over my algebra problems.


The full sentence reads "The book design, cover design, and cover photo were created by my friend Daniel
Will-Harris, noted author and designer (www.Will-Harris.com), who used to play with rub-on letters in
junior high school while he awaited the invention of computers and desktop publishing, and complained
of me mumbling over my algebra problems."  The part of the sentence that reads "and complained of me
mumbling over my algebra problems," is wrong; more specifically, the "me mumbling" is wrong.  It should
be "my mumbling," as what he complained about was the mumbling, not you.  Also, as it stands now, it
could be read to mean that he complained about you while mumbling over your algebra problems; that most
likely is not what you meant.

Add a comment to this suggestion
Comment ID: 1000921-121134-geldin_-mac-_com.cmt
From: Jeremy Sherman
Revision 11 Chapter:Introduction
Search for Text: It then examines subject of directory paths and file names.


Under the section of the Introduction entitled "Chapter 5: Hiding the Implementation," you will find
"It then examines subject of directory paths and file names."  This sentence is missing a "the" before
the "subject."

Add a comment to this suggestion
Comment ID: 1000921-101924-geldin_-mac-_com.cmt
From: Jeremy Sherman
11 Chapter:Preface
Search for Text: one-on-one, but also in groups and, as a planet.


The full sentence is "I think that perhaps the results of the communication revolution will not be seen
from the effects of moving large quantities of bits around; we shall see the true revolution because
we will all be able to talk to each other more easily: one-on-one, but also in groups and, as a planet."



The error is in the latter half of the sentence, after the colon ("one-on-one, but also in groups and,
as a planet.").  The comma after the "and" has no reason to be where it is and makes for a really strange
break when reading aloud.  The post-colon section should read: "one-on-one, but also in groups and as
a planet."

Add a comment to this suggestion
Comment ID: 1000921-090907-abha_t_-rocketmail-_com.cmt
From: Abha Thakur
PDF/Printed Chapter:Chapter 14
Search for Text: The program ThreadGroup1.java on page 886

// Get the system thread & print its Info:
		ThreadGroup sys = Thread.currentThread().getThreadGroup();
		sys.list(); // (1)
---------------

this section is supposed to display the name of the Threadgroup as system, but the output I obtained
is "main" same as the name of the main thread "main". 
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
// Look at a new thread's priority before
		// and after changing it:
		t = new Thread(g1, "C");
		g1.list(); // (6)
--------------------------------------------------

This section says that the output of the program should show the default priority of the new thread "C"
to be 6, independent of what the maximum priority of the ThreadGroup to which it belongs to is. But C
started with a priority 3 instead of 6, 3 being the priority of ThreadGroup g1 to which it was assigned.

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Thread[] all = new Thread[sys.activeCount()];
		sys.enumerate(all);
		for(int i = 0; i < all.length; i++)
			if(!all[i].isAlive())
				all[i].start();
		// Suspends & Stops all threads in
		// this group and its subgroups:
		System.out.println("All threads started");
		sys.suspend(); // Deprecated in Java 2
		// Never gets here...
		System.out.println("All threads suspended");
		sys.stop(); // Deprecated in Java 2
		System.out.println("All threads stopped");
------------------------------------------

You cannot get hold of the active threads by using enumerate() because active according to JDK1.3 SE
documentation is a thread that was started but never stopped, and none of the Threads in that program
were ever started, they are 'new' not 'runnable'; since you cannot get a reference to them this way,
the output shown in the book saying the std output shows "All threads started" is never reached, instead
a nullPointerException is thrown.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Comment:Code compiled using JDK1.3 SE compiler, on Windows 98.

Add a comment to this suggestion
Comment ID: 1000921-080459-markvenn_-yahoo-_co-_uk.cmt
From: Mark Venn
Revision 11 Chapter:4
Search for Text: non-static Bowl b3 prior


P. 226 The sentence "Note that Cupboard creates a non-static Bowl b3 prior to the static definitions."



I find this misleading. I think the point Bruce is trying to make here is that although non-static Bowl
b3 is defined before the static Bowl objects in the Cupboard class definition, b3 will be created after
the static Bowl objects b4 and b5 (as demonstrated by the console output the program produces).

Regards

Add a comment to this suggestion
Comment ID: 1000917-020050-rothgi_-nswccd-_navy-_mil.cmt
From: Gary Roth
Book Chapter:9
Search for Text: Collecions

Misspelling.  Should be Collections.  Occurs in a comment to Reverse.java.

Add a comment to this suggestion
Comment ID: 1000916-175554-oamdg_mb_-yahoo-_com.cmt
From: Milan Babiak
Release 11 Chapter:The Java I/O System/Object serialization/Finding the class - page 619
Search for Text: This program opens the file and reads in the object mystery successfully.

The example program //: c11:xfiles:ThawAlien.java reads serialized object from the file "X.file"

//: c11:xfiles:ThawAlien.java
// Try to recover a serialized file without the
// class of object that's stored in that file.
import java.io.*;

public class ThawAlien {
   public static void main(String[] args)
   throws IOException, ClassNotFoundException {
      ObjectInputStream in =
         new ObjectInputStream(
            new FileInputStream("X.file"));
      Object mystery = in.readObject();           // line 12
      System.out.println(mystery.getClass());   // line 13
   }
} ///:~

In the book is written:

"This program opens the file and reads in the object mystery successfully. However, as soon as you try
to find out anything about the object—which
requires the Class object for Alien—the Java Virtual Machine (JVM)
cannot find Alien.class (unless it happens to be in the Classpath, which
it shouldn’t be in this example). You’ll get a ClassNotFoundException."

That means, I should get ClassNotFoundException in the line 13:

   System.out.println(mystery.getClass());

But I got this exception already in the preceding line 12:

   Object mystery = in.readObject();


The fact that class of the object is needed already in the process of reading the object (not until in
the getClass() method call) is written in the JDK 1.2.2 documentation:

   java.io.ObjectInputStream, method:

   public final Object readObject()
                        throws OptionalDataException,
                               ClassNotFoundException,
                               IOException
Method Detail:


"Read an object from the ObjectInputStream. The class of the object, the signature of the class, and
the values of the non-transient and non-static fields of the class and all of its supertypes are read.
"

Add a comment to this suggestion
Comment ID: 1000916-175535-oamdg_mb_-yahoo-_com.cmt
From: Milan Babiak
Release 11 Chapter:The Java I/O System/Object serialization/Finding the class - page 619
Search for Text: This program opens the file and reads in the object mystery successfully.

The example program //: c11:xfiles:ThawAlien.java reads serialized object from the file "X.file"

//: c11:xfiles:ThawAlien.java
// Try to recover a serialized file without the
// class of object that's stored in that file.
import java.io.*;

public class ThawAlien {
   public static void main(String[] args)
   throws IOException, ClassNotFoundException {
      ObjectInputStream in =
         new ObjectInputStream(
            new FileInputStream("X.file"));
      Object mystery = in.readObject();           // line 12
      System.out.println(mystery.getClass());   // line 13
   }
} ///:~

In the book is written:

"This program opens the file and reads in the object mystery successfully. However, as soon as you try
to find out anything about the object—which
requires the Class object for Alien—the Java Virtual Machine (JVM)
cannot find Alien.class (unless it happens to be in the Classpath, which
it shouldn’t be in this example). You’ll get a ClassNotFoundException."

That means, I should get ClassNotFoundException in the line 13:

   System.out.println(mystery.getClass());

But I got this exception already in the preceding line 12:

   Object mystery = in.readObject();


The fact that class of the object is needed already in the process of reading the object (not until in
the getClass() method call) is written in the JDK 1.2.2 documentation:

   java.io.ObjectInputStream, method:

   public final Object readObject()
                        throws OptionalDataException,
                               ClassNotFoundException,
                               IOException
Method Detail:


"Read an object from the ObjectInputStream. The class of the object, the signature of the class, and
the values of the non-transient and non-static fields of the class and all of its supertypes are read.
"

Add a comment to this suggestion
Comment ID: 1000916-170853-oamdg_mb_-yahoo-_com.cmt
From: Milan Babiak
Release 11 Chapter:The Java I/O System/Compression/Java ARchives (JARs)
Search for Text: jar cmf myJarFile.jar myManifestFile.mf *.class

Following jar command example:

   jar cmf myJarFile.jar myManifestFile.mf *.class

should be as follows:

   jar cfm myJarFile.jar myManifestFile.mf *.class


The letters 'm' and 'f' right after jar command need to be exchanged, because jar documentation states:


"   Usage: jar {ctxu}[vfm0M] [jar-file] [manifest-file] [-C dir] files ...
...

The manifest file name and the archive file name needs to be specified in the same order the 'm' and
'f' flags are specified. ..."

Add a comment to this suggestion
Comment ID: 1000916-052929-elam_-phone2networks-_com.cmt
From: Elam Birnbaum
Print Edition Chapter:7, pages 343-344
Search for Text: 343 344 extending diagram


This is more of an organizational comment. On pages 343 and 344, the same diagram is repeated. From the
surrounding text, it seems like the second diagram (on page 344) is meant to show the problems with downcasting.
A new diagram is probably in order...

Add a comment to this suggestion
Comment ID: 1000916-044209-michel_maquino_-ig-_com-_br.cmt
From: Michel Masiero de Aquino
Revision 11 Chapter:04

Search for Text: Here's an example that shows both overloaded constructor and overloaded ordinary methods
:

import java.util.*; // Bruce, this import not is necessary.

class Tree {
	int height;
	Tree() {
		prt("Plantando a semente");
		height = 0;
	}
	Tree(int i) {
		prt("Criando uma nova µrvore que ‚ " + i);
		height = i;
	}
	void info() {
		prt("A µrvore tem " + height + " de altura");
	}
	void info(String s) {
		prt(s + ": A µrvore tem " + height + " de altura");
	}
	static void prt(String s) {
		System.out.println(s);
	}
}

public class OverloadingOrder {
	public static void main(String[] args) {
		for (int i=0; i <5; i++) {
			Tree t = new Tree(i);
			t.info();
			t.info("m‚todo de Sobrecarga de Construtor");
		}
		new Tree();
	}
}

/*
I love your book!! It's the best.
Thanks a lot.

Eu amei o seu livro!! Ele é muito bom.
Muito Obrigado.
*/

Add a comment to this suggestion
Comment ID: 1000909-071306-maindude_-cyberdude-_com.cmt
From: Bob Williams
Annotated Solutions Guide - 2nd Edition Chapter:2
Search for Text: c02:Storage.java

In this example, I believe the statement...

System.out.println("storage(s) = " + storage(s));

should be

System.out.println("Storage(s) = " + Storage(s));


please advise me if this is correct, as I hope to be able to change my resume to include the following
accomplishment "Helped to debug Bruce Eckel's java programs." This will go in right in front of "Helped
Al Gore invent the internet". ;))

Add a comment to this suggestion
Comment ID: 1000905-011543-rothgi_-nswccd-_navy-_mil.cmt
From: Gary Roth
Print Edition Chapter:9
Search for Text: //: com: bruceeckel:util:Arrays2.java


There is a bug in the print(Object[] a, int from, int to) methods.  This is a problem in all of the methods,
not just the Object[] method.


If from, to is 0, a.length, then print works correctly.  However, if to is anything other then a.length,
then print prints 1 fewer array member than it should.  For example, for print(a, 2, 4), only the a[2]
and a[3] will
be printed, not a[4].  This is because of the loop "for(int i = from; i < to; i++)".

Add a comment to this suggestion
Comment ID: 1000903-151631-fungkw_-hongkong-_com.cmt
From: King-Wai Fung
PDF Chapter:9

Search for Text: In the last case, all the elements of s1 point to the same object, but s2 has five unique
objects.


In fact, the "five objects" in s2 are one single object. You can see the difference from the following
modified code:

//: c09:ComparingArrays.java
// Using Arrays.equals()
import java.util.*;

public class ComparingArrays {
  public static void main(String[] args) {
    int[] a1 = new int[10];
    int[] a2 = new int[10];
    Arrays.fill(a1, 47);
    Arrays.fill(a2, 47);
    System.out.println(Arrays.equals(a1, a2));
    a2[3] = 11;
    System.out.println(Arrays.equals(a1, a2));
    String[] s1 = new String[5];
    Arrays.fill(s1, "Hi");

    // Modified:
    String[] s2 = {"Hi", "Hi", "Hi", "Hi", new String("Hi")};
    System.out.println(s1[0] == s2[0]); // true
    System.out.println(s2[0] == s2[1]); // true
    System.out.println(s1[0] == s2[4]); // false
    System.out.println(s2[0] == s2[4]); // false

    System.out.println(Arrays.equals(s1, s2));
  }
} ///:~

Add a comment to this suggestion
Comment ID: 1000902-203002-grzegorz_o_-hector-_com-_pl.cmt
From: Grzegorz Olszewski
Release 11 Chapter:8
Search for Text: // Cannot access a member of the interface

.
.
.
public static void main(String[] args) {
A a = new A();
// Can't access A.D:
//! A.D ad = a.getD();
// Doesn't return anything but A.D:
//! A.DImp2 di2 = a.getD();
// Cannot access a member of the interface:
//! a.getD().f();     <---------------------------------------
// Only another A can do anything with getD():
A a2 = new A();
a2.receiveD(a.getD());
}


I believe you can access function a.getD().f(). a.getD() returns reference to class A.DImp2 upcasted
to interface A.D. Try uncomment signed line - it works.


From: zach knoll [picof_-aol-_com]

I second that last post. Not only does that work but you can more explicitly say, A.DImp2 watchThis =
new A().new DImp2();

From: Paulo Santos [pauloya_-yahoo-_com]
I tried uncommented signed line and it didn't work. 
This is what i got:

-----------------------------------------------
>javac NestingInterfaces.java

NestingInterfaces.java:85: f() in A.D is not defined in a public class or interface; cannot be accessed
from outside package
    a.getD().f();
          ^
1 error
-----------------------------------------------
So, I would say the book is correct on this one.


Add a comment to this suggestion
Comment ID: 1000828-060327-Li-Feng_Zhang_-baylor-_edu.cmt
From: Li-Feng Zhang
Release 11 Chapter:9
Search for Text: c09: ArraySize.java


The output of this program(c09:ArraySize) listed on the book(page 411) is incorrect. It is a small mistake.
Hard to discribe. Very easy easy to find out by simply running the code.

Add a comment to this suggestion
Comment ID: 1000824-021949-ronlusk_-alum-_mit-_edu.cmt
From: Ron Lusk
Paper, 1st(?) printing Chapter:15
Search for Text: implemeted

"implemented"

Truly a nit

Also, in same chapter: decide on a standard form: "EJBs" (common) vs "EJB's" (appears once)

"--including mainframes that do not have visual displays--An EJB..."
try making that "--an EJB"



Add a comment to this suggestion
Comment ID: 1000824-021542-ronlusk_-alum-_mit-_edu.cmt
From: Ron Lusk
Paper, 1st(?) printing Chapter:15
Search for Text: another vendors' application server

"another vendor's application server"

Truly a nit

Add a comment to this suggestion
Comment ID: 1000824-021458-ronlusk_-alum-_mit-_edu.cmt
From: Ron Lusk
Paper, 1st(?) printing Chapter:15
Search for Text: if a certain criteria

if a certain criterion (or "if certain criteria")

Truly a nit

Add a comment to this suggestion
Comment ID: 1000824-020544-ronlusk_-alum-_mit-_edu.cmt
From: Ron Lusk
Paper, 1st(?) printing Chapter:Index
Search for Text: inizialization: lazy - 273

Spelling fix

Add a comment to this suggestion
Comment ID: 1000821-172923-lviggiano_-tiscalinet-_it.cmt
From: Luigi Rocco Viggiano
may be 10 ? Chapter:Chapter 3 page 155
Search for Text: an Oak can be cast to a Tree and vice-versa, but not foreign type such as a Rock.


In my opinion that's not so true: you cannot always cast a superclass to a child type class. In other
words, an Oak is a Tree, but not all Trees are Oaks. I.E. if I create a Pine inheriting from Tree, I
can cast it to a Tree, but after that I cannot cast it again to an Oak, because... A Pine is not an Oak.
In this cas I am unable to cast a tree to the Oak.
I'm continuing reading it, that's fantastic.

Thanks for the book and regards!
Luigi

Add a comment to this suggestion
Comment ID: 1000820-200956-andrius_-vb-_lt.cmt
From: Andrius Masiulis
Revision 11 Chapter:04
Search for Text: that reference is given a special value of null (which is a Java keyword

null is not a java kyeword but literal

From: Luigi Rocco Viggiano [lviggiano_-tiscalinet-_it]
A literal is also a keyword. it's an hinerited type :)

Ciao
Luigi

Add a comment to this suggestion
Comment ID: 1000820-181326-lviggiano_-tiscalinet-_it.cmt
From: Luigi Rocco Viggiano
may be 10 ? Chapter:3 page 152 "The comma operator"

Search for Text: The sole place that the comma operator is used in java is in for loops, which will be
described later in this chapter.

I think it's not very correct.
Also in declaration you can use the comma operator as follows:

int a, b=10, c;

I don't remember now if there are more places where the comma can be used even.

Thanks for the great book. I buyed the "paper" version (but in italy it's very expensive).
Regards Luigi

From: Larry Leonard [Larry_-DefinitiveSolutions-_com]
That's a "comma separator", not a "comma operator" - see page 175.

Add a comment to this suggestion
Comment ID: 1000813-134303-bcowen_-osmotic-_com.cmt
From: Bradley Cowen
2nd, Release 11 Chapter:2
Search for Text: @exception


The @throws method documention tag is listed. However, in the "HelloDate.java" program example, the @exception
tag is used with no mention that @throws is a synonym for @exception added in Javadoc 1.2.

Add a comment to this suggestion
Comment ID: 1000813-024734-dhelrod_-rivendell-_com.cmt
From: David Elrod
Book - 1st Printing Chapter:2
Search for Text: Everything is an Object

I wish your statements at the beginning of chapter two (including
the title) were true.

However, the primitive data types are not objects.

When I first started using Java, I wanted to do:
  int i = 5;  
  String s = i.toString();

I can understand, from a performance standpoint that the
primitive types might have been considered necessary. (I
would have put the optimization burden on the compiler 
and treated these basic types (char, boolean,int, float, ...)
as "special" objects - like "String".)

I was excited to learn that others had found this to be an
issue, and there there was an Integer class that WAS an object.
I was disappointed to learn that I couldn't do this:

  Integer i = new Integer(5);
  Integer j = new Integer(6);
  Integer k = i * j;
OR
  Integer k = i.mult(j);	// Multipy i * j

If Integer, Double, etc. supported the full set of operations
then one could teach an "Everything Is An Object" approach.

In any case, I think you mislead people when you tell them that
everything is an object. MOST things are objects... :>

David

P.S. Java is the best language I've seen so far for the things I
like to do. Your book is good. I bought version 1, I bought 
version 2, and I'll happily buy version 3. Thanks!


Add a comment to this suggestion
Comment ID: 1000813-021855-dhelrod_-rivendell-_com.cmt
From: David Elrod
Book - 1st printing Chapter:3
Search for Text: Note that boolean is quite limited.

This might be a nit, but there are a number of "other type[s] of 
operations" one might want to perform on a boolean.

You can use the "and", "or", etc. operations to create new booleans
with new more meaningful values.

Suppose you have a "inputPort" object which has a "dataAvailable"
boolean that is tied (via JNI??) to a bit in a device.

Suppose you have a "outputPort" object which has a "okToXmit"
boolean that is tied to a bit in a different device.

You could have something like:

boolean okToGo = inputPort.dataAvailable & outputPort.okToXmit;

You might then use okToGo in other calculations before finally
testing it.



Add a comment to this suggestion
Comment ID: 1000806-205825-andrius_-vb-_lt.cmt
From: Andrius Masiulis
Revision 11 Chapter:14: Multiple Threads
Search for Text: JavaBeans revisited

Very serious logical error !!!

// Make a shallow copy of the List in case 
// someone adds a listener while we're 
// calling listeners:
        synchronized(this) {
          lv = (ArrayList)actionListeners.clone();
        }
// Call all the listener methods:
        for(int i = 0; i < lv.size(); i++)
          ((ActionListener)lv.get(i))
            .actionPerformed(a);

What happens if someone removes a listener ? The user can still get message
for his acction listener though it was removed ! I think this can lead to 
unpredictable results.

Add a comment to this suggestion
Comment ID: 1000804-193643-simon-_blanchard_-philips-_com.cmt
From: Simon Blanchard
Apr 24 Chapter:All
Search for Text: ' or "

In machines that do not have the Verdana or Georgia fonts installed the
the apostrophe and inverted comma (' and ") do not appear. This is because
they are encoded in the HTML as ’. My suggestion is to run a perl script
over the HTML before publishing to replace the numbers with the real character.
In this way it will display nicely on all browsers.

Background: I'm reading TIJ on the Psion Series 7 - which make a very nice ebook
but there is no support in the browser for the fonts.

Thanks!

From: Rob Kelley [composer_-thekeyboard-_com]