Thinking in Java, 3nd Edition

HTML is now generated by a new tool called LogicTran (http://www.Logictran.
com). ..... First I stumbled upon the PDF version of Thinking in Java. Even before I
.... Exercises. The CD ROM. Source code. Coding standards. Java versions.
Errors.

Part of the document


Note: This document requires the installation of the fonts Georgia, Verdana
and Andale Mono (code font) for proper viewing. These can be found at:
http://sourceforge.net/project/showfiles.php?group_id=34153&release_id=10535
5
Modifications in Revision 4.0 (11/20/02 - Final version as will be in
print)

. Incorporated remainder of copyedits.

. Preface and introduction completed.

. Index completed

. Rewrote debugging section in Chapter 15 that was still raw

. Various corrections based on reviews

Modifications in Revision 3.0 (10/29/02)

. Reorganized chapters into their final form and numbering. Split Chapter 1
by moving "Analysis and design" to Chapter 16.

. Modified the description of the chapters in the introduction. (This needs
to be revisited again.

. Finished threading chapter. Dining philosophers problem added to
threading chapter.

. Edited/rewrote chapters 1 - 11, 14 and Appendix A, B & D, which went to
production.

. Added Applet Signing and Java Web Start sections to "Creating Windows and
Applets."

. Added examples showing threading in "Creating Windows and Applets."

. Added improved access control to most classes (more private fields, in
particular).

. Made general improvements throughout the code base.

. Changed cleanup( ) to dispose( )

. Changed "friendly" to "package access"

. Changed "function" to "method" most places

. Added Preferences API section

. Removed Microsoft EULA (no longer needed for CD)

. Rewrote c14:ShowAddListeners.java to use regular expressions; refactored

. Renamed "death condition" to "termination condition"

Modifications in Revision 2.0 (9/13/2002)

. Completed part of the rewrite of the threading chapter. This simplifies
the introduction to threading and removes all the GUI examples, so that
the threading chapter may be moved to appear earlier in the book.

. Reorganized material into reasonably final form, and assigned chapter
numbers. Chapters may still migrate.

. Finished com.bruceeckel.simpletest framework and integrated all test-
instrumented examples back into the main book. Added prose for testing
system in Chapter 15. Also updated most examples in book to reflect
improvements in testing system. Note: we are still refactoring this code
to make it simpler. Stay tuned.

. Added sections on JDK 1.4 assertions, including design-by-contract, to
Chapter 15.

. Added JUnit introduction and example to Chapter 15.

. Changed "static inner class" to "nested class."

. Modified c04:Garbage.java so it wouldn't fail on fast machines, added
description.

. Moved BangBean2.java into the GUI chapter, since the non-GUI threading
chapter will now appear before the GUI chapter.

Modifications in Revision 1.0 (7/12/2002):

. Changed to email-based BackTalk system, which is much simpler to use and
may be used while reading the document offline.

. Added "Testing and Debugging" chapter, currently numbered 15. This
includes a simple testing system and an introduction to JUnit, as well as
a thorough introduction to Logging and an introduction to using debuggers
and profilers.

. Added test framework to examples in the book. Not all examples are fully
tested yet, but most are at least executed. Comment flags on examples
indicate the testing status of each. Significant change: program output
is displayed and tested directly in the source, so readers can see what
the output will actually be.

. Change to Ant as the build tool, added package statements to disambiguate
duplicate names so Ant won't complain. Running Ant on the book not only
compiles but also runs the aforementioned tests.

. HTML is now generated by a new tool called LogicTran
(http://www.Logictran.com). Still learning to use this one, so early
versions will be a bit rough.

. Replaced Thread Group section in multithreading chapter.

. Removed JNI appendix (available in the electronic 2nd edition on the CD
or via download from www.MindView.net)

. Removed Jini section (available in the electronic 2nd edition on the CD
or via download from www.MindView.net)

. Removed Corba section (available in the electronic 2nd edition on the CD
or via download from www.MindView.net) after talking to Dave Bartlett
(Corba & XML expert), who observed that Corba has gone quiet and everyone
has gone up a level to the use of XML for system integration instead of
Corba.

. Made a number of technical corrections suggested over the last 2 years.
Most suggestions have been archived but not made yet.

Todo:

. Add "cloud of teachers, mentors, consultants" re: Larry's suggestion

. Check for double spaces in text, replace ( ) with ( ), correct em-dashes
- with -

. Refresh TOC page numbers and Index




Next edition:

. A chapter on strings

. A chapter on generics

. Better unit testing


Thinking
in
Java

Third Edition

Bruce Eckel
President, MindView, Inc.


Comments from readers:

Much better than any other Java book I've seen. Make that "by an order of
magnitude"... very complete, with excellent right-to-the-point examples
and intelligent, not dumbed-down, explanations ... In contrast to many
other Java books I found it to be unusually mature, consistent,
intellectually honest, well-written and precise. IMHO, an ideal book for
studying Java. Anatoly Vorobey, Technion University, Haifa, Israel

One of the absolutely best programming tutorials I've seen for any
language. Joakim Ziegler, FIX sysop

Thank you for your wonderful, wonderful book on Java. Dr. Gavin Pillay,
Registrar, King Edward VIII Hospital, South Africa

Thank you again for your awesome book. I was really floundering (being a
non-C programmer), but your book has brought me up to speed as fast as I
could read it. It's really cool to be able to understand the underlying
principles and concepts from the start, rather than having to try to
build that conceptual model through trial and error. Hopefully I will be
able to attend your seminar in the not-too-distant future. Randall R.
Hawley, Automation Technician, Eli Lilly & Co.

The best computer book writing I have seen. Tom Holland

This is one of the best books I've read about a programming language...
The best book ever written on Java. Ravindra Pai, Oracle Corporation,
SUNOS product line

This is the best book on Java that I have ever found! You have done a
great job. Your depth is amazing. I will be purchasing the book when it
is published. I have been learning Java since October 96. I have read a
few books, and consider yours a "MUST READ." These past few months we
have been focused on a product written entirely in Java. Your book has
helped solidify topics I was shaky on and has expanded my knowledge base.
I have even used some of your explanations as information in interviewing
contractors to help our team. I have found how much Java knowledge they
have by asking them about things I have learned from reading your book
(e.g., the difference between arrays and Vectors). Your book is great!
Steve Wilkinson, Senior Staff Specialist, MCI Telecommunications

Great book. Best book on Java I have seen so far. Jeff Sinclair, Software
Engineer, Kestral Computing

Thank you for Thinking in Java. It's time someone went beyond mere
language description to a thoughtful, penetrating analytic tutorial that
doesn't kowtow to The Manufacturers. I've read almost all the others-only
yours and Patrick Winston's have found a place in my heart. I'm already
recommending it to customers. Thanks again. Richard Brooks, Java
Consultant, Sun Professional Services, Dallas

Bruce, your book is wonderful! Your explanations are clear and direct.
Through your fantastic book I have gained a tremendous amount of Java
knowledge. The exercises are also FANTASTIC and do an excellent job
reinforcing the ideas explained throughout the chapters. I look forward
to reading more books written by you. Thank you for the tremendous
service that you are providing by writing such great books. My code will
be much better after reading Thinking in Java. I thank you and I'm sure
any programmers who will have to maintain my code are also grateful to
you. Yvonne Watkins, Java Artisan, Discover Technologies, Inc.

Other books cover the WHAT of Java (describing the syntax and the
libraries) or the HOW of Java (practical programming examples). Thinking
in Java is the only book I know that explains the WHY of Java; why it was
designed the way it was, why it works the way it does, why it sometimes
doesn't work, why it's better than C++, why it's not. Although it also
does a good job of teaching the what and how of the language, Thinking in
Java is definitely the thinking person's choice in a Java book. Robert S.
Stephenson

Thanks for writing a great book. The more I read it the better I like it.
My students like it, too. Chuck Iverson

I just want to commend you for your work on Thinking in Java. It is
people like you that dignify the future of the Internet and I just want
to thank you for your effort. It is very much appreciated. Patrick
Barrell, Network Officer Mamco, QAF Mfg. Inc.

I really, really appreciate your enthusiasm and your work. I download
every revision of your online books and am looking into languages and
exploring what I would never have dared (C#, C++, Python, and Ruby, as a
side effect) . I have at least 15 other Java books (I needed 3 to make
both JavaScript and PHP viable!) and subscriptions to Dr. Dobbs, JavaPro,
JDJ, JavaWorld, etc., as a result of my pursuit of Java (and Enterprise