Eckel OBJECTives
Free Book: Thinking in Java

Revision 9, August 16, 1997

This page is a (revisited) mirror page

This page was the first mirror published
with the agreement and the cooperation of the original author (Bruce Eckel); it is created and maintained by marc.meurrens@acm.org (http://homepages.ulb.ac.be/~meurrens)
Other mirrors now exist. To save the bandwith, allways use the nearest site to download a large file!

URL of the original document
http://www.EckelObjects.com/javabook.html by Bruce Eckel: Bruce@EckelObjects.com or Eckel@aol.com. In this (revisited) mirror page, we also include a description of the book's chapters mirrored from http://www.EckelObjects.com/java.html and an important errata note.

URL of our page(s) on "Java OO Design & Coding Standards"
(where this document is referred as detailled below):
http://www.ulb.ac.be/esp/ip-Links/Java/joodcs/index.html
[back]

"Thinking in Java" (by Bruce Eckel)
is a revisited mirror (published with the agreement and the cooperation of the original author) of http://www.EckelObjects.com/javabook.html where you can download this free book in Acrobat (www.adobe.com) PDF format: Thinking in Java Rev. 9, August 16, 1997 TJAVA9.PDF (2678 kb). Downloading the PDF file from the original site is quite difficult. The TJAVA9.PDF Acrobat file, the tjava9W95.zip file (1557 kb --> a 4349 kb WORD file), the CodePackagertj9code.zip (122 kb --> 3 files, 1070 kb) and the CodePackager java source are mirrored on our site. A detailled description of all chapters and an important errata note are also available. This book has been written by Bruce Eckel (Bruce@EckelObjects.com), also author of "Thinking in C++".

This important ressource was suggested (July 6, 1997) by werner.ramaekers@ping.be (or wra@bejug.org) and yves.callewaert@ficsgrp.com (BeJUG voting members).

Pre-prepared links (to this document)

A list of approx. 363 "pre-prepared" links to this page is available at URL http://www.ulb.ac.be/esp/ip-Links/Java/joodcs/eckel-LinksTo.html.
These links are (or will be) used in other pages related to "OO design and Coding Standards".

Full table of content of the book

Full table of content of the book (revision 8) is available here.

Revisions

For automatic notification when the book is revised, when it is printed and when the CD Rom becomes available, add yourself to the Java mailing list or fill the form below.

Eckel OBJECTives
Free Book: Thinking in Java

Revision 9, August 16, 1997


A table of content of this MIRROR page is available here.
The full table of content of the revision 8 of the book is available here.
For automatic notification when the book is revised, when it is printed and when the CD Rom becomes available, add yourself to the Java mailing list or fill the form below.

This is the book Thinking in Java in Adobe Acrobat (www.adobe.com) format. If you have Acrobat installed properly, the fonts and layout will be similar to the way it will appear when published and bound (I've adjusted the borders to make it cheaper to print, however). The entire book will appear here as it is completed, and will continue to be available in electronic form even after the book is physically printed. Any updates and corrections will appear in the electronic book.

The electronic version of the book will continue to be free. You have permission to print a copy of the book for your own use.

If you like the book, please:

  1. Recommend it to your friends
  2. Create links to this site from your web page
  3. Report any errors or problems you find
  4. When the book is printed (see later) consider buying a copy - it's probably cheaper than the toner cartridge you'll use up. However, if it works well enough for you as an electronic document, great!
  5. Consider coming to one of my public hands-on Java seminars

Revision 8

Much of the change with the revision 8 involves Java 1.1. New sections and projects have been added, and significant portions have been rewritten (For example, the design patterns chapter has been rewritten significantly). Please let me know if you discover discrepancies, particularly places where I've used a concept before it was introduced.

I will be publishing it in Adobe Acrobat (www.adobe.com) from now on. Although it's big, it seems much easier to read electronically, as it looks virtually identical to the way the book will appear in print, so if you want to print it you'll get all the proper fonts and formatting.

Sometimes I get messages saying people are having trouble downloading the book. This is invariably because of network problems, and eventually I hear back that they've been able to download it. Especially if you're downloading it from overseas, try connecting when everyone's asleep in your country; that often works. Keep trying...

Revision 9, August 16, 1997

First let me apologize: there's no index yet which is what I was promising for this revision. But so many folks sent in such good suggestions and corrections that I spent all my time with those (in addition I've been updating and recording lessons for the CD Rom, which continues and which I'm quite pleased with). I've got to say that putting the book up on the Web has made this the best publishing experience I've had (and the same thing will happen with the 2nd editon of "Thinking in C++" which will begin when this book is published).

I think you'll find that the corrections and new material is worth not having an index (which I really do plan to focus on for the next revision). Significant changes include:

  1. New formats! The book is now available in several additional formats to make it easier for you to use.
  2. FTP. You'll see if you hover your mouse over the links that all the files are in an FTP directory. If you want to use FTP directly, connect your FTP program to WWW.MindView.net and move to pub/Eckel. You'll find the files there.
  3. The networking chapter is refined and (I think) pretty much finished. In this revision I added examples showing how to create Java applets to talk to CGI programs on the server, and how to write those CGI programs (both GET and POST) in C++ (there's a very nice reusable class that automatically parses the CGI data into fields and values).
  4. The polymorphism chapter has changes and additions in the "nested classes" section since several people asked for clarification. I added one of my favorite examples, the greenhouse controller, to show you why nested classes are great.
  5. More clarification and examples on object serialization.
  6. The copyright notice for the source-code files has changed; it is intended to make it easier to use code in classroom situations.
  7. And tons of other corrections, changes, etc. too numerous to mention. The suggestions and corrections have been flowing in, and I haven't been idle. To see all the differences, you can download a zip file containing the plain text form of both rev 8 and rev 9 (see later this page) and run them through your favorite compare program.

As the book gets closer to publication, one thing that would be very useful is exercises – these are always hard for me to come up with so any suggestions will be appreciated. Also please continue sending the same sorts of corrections and suggestions you've been sending; although I can't promise to make all the changes I carefully consider each one since these are what have been the source of great improvements in the book.

Errata & addenda

Nobody is perfect.

public constants in interfaces
This topic will probably be entirely revised in revision 10.
While you are waiting for revision 10, please have a carefull look at the IMyConsts sample interface where the use of public constants is illustrated.
(The source file is also here.)
This file was initialy created as a support of a technical discussion between Bruce Eckel (author of the book) & Marc Meurrens (author of this page).

index
It is the intention of Bruce to publish a full index. Probably in revision 10.

Cheaper Printing...

I assumed that most people were reading it online, but surveys have found that most people seem to be printing it. Because of this, I've reformatted the book so that it requires less paper and is cheaper for you to print. This will not be how the published version looks - the paper size and formatting will be different. If you report errors, be sure to include some fragment of the text around it and I'll just search for that. If you find yourself going through and marking a lot of your pages, feel free to send the marked-up pages to:

Bruce Eckel
20 Sunnyside Ave, Suite A129
Mill Valley, CA 94941

Thanks!

Mirror sites:

In the U.S., the Chicagoland Java User Group (CJUG) maintains a mirror at http://www.cjug.org/download/javabook.html.

Overseas locations often have trouble downloading the book. In Europe, the Belgian User's group has a mirror site at:
http://www.ulb.ac.be/esp/ip-Links/Java/joodcs/EckelJavaBook.html (the page you are reading now!)

In France, there's a mirror at:
http://www.mygale.org/~guessant/java/eckel/index.html

At a second mirror site in France the files are available for ftp via a 4Mb/s connection at:

In Iceland, contact our colleague Snorri Agnarsson or visit his home page at http://www.hi.is/~snorri or http://www.hi.is/~snorri/097111-97 (if you understand the old nordic)

If you wish to set up a mirror site please inform me so that I can place your URL here.
Use the form located at the end of this page or e_mail Bruce@EckelObjects.com

Bruce Eckel
20 Sunnyside Ave, Suite A129
Mill Valley, CA 94941

Downloads

Thinking in Java PDF File Download

Thinking in Java PDF File Download in small pieces

If you have trouble downloading the PDF file, it has been broken up into separate pieces here (You cannot read the individual pieces with acrobat! You must combine them as subsequently described before trying to read them with acrobat!). Download each file:

  1. TJAVA9PDF.01 (200 Kb) mirrored here t901
  2. TJAVA9PDF.02 (200 Kb) mirrored here t902
  3. TJAVA9PDF.03 (200 Kb) mirrored here t903
  4. TJAVA9PDF.04 (200 Kb) mirrored here t904
  5. TJAVA9PDF.05 (200 Kb) mirrored here t905
  6. TJAVA9PDF.06 (200 Kb) mirrored here t906
  7. TJAVA9PDF.07 (200 Kb) mirrored here t907
  8. TJAVA9PDF.08 (200 Kb) mirrored here t908
  9. TJAVA9PDF.09 (200 Kb) mirrored here t909
  10. TJAVA9PDF.10 (200 Kb) mirrored here t910
  11. TJAVA9PDF.11 (200 Kb) mirrored here t911
  12. TJAVA9PDF.12 (200 Kb) mirrored here t912
  13. TJAVA9PDF.13 (200 Kb) mirrored here t913
  14. TJAVA9PDF.14 (200 Kb) mirrored here t914
  15. TJAVA9PDF.15 (78 Kb) mirrored here t915
Then combine the files. In DOS (where I know it works), you can use the following command:

copy /b tjava9pdf.01+tjava9pdf.02+tjava9pdf.03+tjava9pdf.04+tjava9pdf.05+tjava9pdf.06+tjava9pdf.07+tjava9pdf.08+tjava9pdf.09+tjava9pdf.10+tjava9pdf.11+tjava9pdf.12+tjava9pdf.13+tjava9pdf.14+tjava9pdf.15 tjava9.pdf

In Unix, you can say:

cat tjava9pdf.* > Tjava9.pdf

If you're curious, here's the C++ source code for the tool that did the job: BREAKUP.CPP

Thinking in Java in RTF format

The book is now available in RTF which should work on many platforms and may make it easier for you to use.

Download Version 9 in zipped RTF format

Thinking in Java in Word 97 format

The book is now available in Word97 format for Windows machines. If you don't have Word97, you can download a free viewer for either Windows 3.1 or Win95/NT at http://www.microsoft.com/word.

This version is easier to navigate (you can, for example, click on the page numbers in the table of contents to move to that page, and doing finds is faster and easier than in acrobat). Also you may have an easier time printing it.

One of the reasons for providing this is for the technical readers, to make it easier for them to find and report errors. Because of this, I may be placing interim versions up in Word97/Word95 only. The acrobat version will only reflect the major revisions since that is much more difficult.

This is exactly the document that I'm working on, without any modifications.

Download the August 18, 1997 version in zipped Word97 format

Thinking in Java in Word 95/Word 6.0 format

The book is now available in Word95/Word 6.0 format, if you have those versions (this includes the Macintosh), for similar reasons as the Word97 format.

Download the August 18, 1997 version in zipped Word95/Word 6.0 format
mirrored here: tjava9W95.zip (1557 bk --> tjava9W95.doc 4349 kb)

Differences between versions

  • From 7 to 8
  • From 8 to 9

    Diffs between version 7 and version 8

    This is a relatively crude "diff" of the text between version 7 and 8, but you may find it useful. EckelDiffs.txt

    Diffs between version 8 and version 9

    Hunting around for a program that would output a text file with the differences, most of what I found graphically showed the differences and allowed you to navigate. Finally I realized I should just give you the plain text source for both versions and let you use your favorite diff program to see the differences yourself.

    Download the text source for both versions for comparison (diffsrc9.zip, 918K) mirrored here

    Source code for Thinking in Java

    As you'll discover in Chapter 17, I've created a program to extract the code and package it into an archive. This same program is used to unpack it, using Java library routines that understand your local system's directory structure as well as the end-of-line terminators. Thus, it should unpack properly onto any machine where the Java libraries are properly implemented. The file itself is in Java's "generic" text format so even if you have trouble on a particular machine you may be able to modify the CodePackager.java program to compensate (as a last resort, you can pull pieces of text out of the file by hand).

    Steps for installing source code on your machine:

    1. Download the "pseudo-packed" (the files are combined with headers between each one) source code archive tjsource.pck along with the source code for the program CodePackager.java in the zipped file tj9code.zip mirrored on our site tj9code.zip (122 kb --> 3 files, 1070 kb) (also mirrored: CodePackager.java)
    2. Unzip the file using a 32-bit Zip program that supports long file names (otherwise the names of the files will be truncated and nothing will work).
    3. Download the source code for the program CodePackager.java (or unzip it from tj9code.zip).
    4. Compile CodePackager.java with a Java 1.1 compiler. You must type the line exactly as you see here:
      javac CodePackager.java
      taking care to get the capitalization right. The Java compiler is case sensitive. Note that if you try to compile it with a pre-1.1 compiler it won't work; you'll get error messages. Much of the code in the book is based on Java 1.1, also.
    5. To extract all the code in directories off the current directory, run the program like this:
      java CodePackager tjsource.pck
    6. To extract all the code in directories off a different directory, run the program like this:
      java CodePackager tjsource.pck c:\full\alternate\directory\path
    7. MacOS users, please see the Thinking in Java MacOS Installation page.

    This is a new experiment and so there may be glitches at first. If you have problems, let me know at Bruce@EckelObjects.com, especially if you can tell me the solution for a particular platform.

    Auto-compilation program for Windows95

    This is a program written in C++ that moves through all the directories and compiles all the Java programs, one at a time, in each directory (by compiling them one at a time you can avoid conflicts that sometimes arise). This is the uncompressed executable jc_all.exe. The source code jc_all.cpp is written and compiled with Borland C++ (you can download a demo version at www.Borland.com) and it uses Borland's directory listing libraries; if you want to re-compile it with Microsoft C++ you'll have to make some changes to the source code.

    The printed version of Thinking in Java

    I hope to have a printed version of the book available in September. My literary agent (cmoore@moorelit.com) is currently talking to publishers. Add yourself to the Java mailing list if you'd like to be notified when the book is printed. Or send an e_mail to (Bruce@EckelObjects.com). Or use the form below.

    1. introduction to objects
    2. everything is an object
    3. controlling program flow
    4. initialization & cleanup
    5. hiding the implementation
    6. reusing classes
    7. polymorphism
    8. holding your objects
    9. error handling with exceptions
    10. the Java IO system
    11. run-time type identification
    12. passing and returning objects
    13. creating windows and applets
    14. multiple threads
    15. network programming
    16. design patterns
    17. projects

    The full table of content of the book is available here.

    A list of approx. 363 "pre-prepared" links to this page is available at URL http://www.ulb.ac.be/esp/ip-Links/Java/joodcs/eckel-LinksTo.html.
    These links are (or will be) used in other pages related to "OO design and Coding Standards".

    Chapters of "Thinking in Java"

    as described at URL http://www.EckelObjects.com/java.html

    Chapter 1: Introduction to Objects
    This chapter is an overview of what object-oriented programming is all about, including the answer to the basic question "what's an object?", interface vs. implementation, abstraction and encapsulation, messages and methods, inheritance and composition, and the all-important polymorphism. Then we'll look at issues of object creation like constructors, where the objects live, where to put them once you create them (answer: in containers), and the magical garbage collector that cleans everything up when it's no longer needed. Other issues will be introduced, like error handling with exceptions and multithreading for responsive user interfaces. We'll also look at what makes Java special and what accounts for its success. This section will also briefly introduce object-oriented programming analysis and design methods. Brief comparisons between Java and C++ will be given throughout the course.

    • the progress of abstraction
    • an object has an interface
    • the hidden implementation
    • reusing the implementation
    • inheritance: reusing the interface
    • overriding base-class functionality
    • is-a vs. is-like-a relationships
    • interchangeable objects with polymorphism
    • dynamic binding
    • the abstract base class
    • object landscapes and lifetimes
    • containers and iterators
    • the singly-rooted hierarchy
    • container libraries and support for easy container use
    • the housekeeping dilemma: who should clean up?
    • exception handling: dealing with errors
    • multithreading
    • persistence
    • Java and the Internet
    • what is the Web?
    • client-side programming
    • a separate arena: applications
    • online documentation
    • summary: Java vs. C++?

    Chapter 2: Everything is an Object
    This chapter gets you to the point that you can write your first Java program, so it must cover the essentials, including: the concept of a "handle" to an object; how to create an object; an introduction to primitive types and arrays; scoping and the way objects are destroyed by the garbage collector; how everything in Java is a new data type (class) and how to create your own classes; functions, arguments, and return values; name visibility and using components from other libraries; the static keyword; comments and embedded documentation.

    • you manipulate objects through handles
    • you must create all the objects
    • where storage lives
    • special case: primitive types
    • arrays in Java
    • you never have to destroy an object
    • scoping
    • scope of objects
    • creating new data types: class
    • fields and methods
    • methods, arguments, and return values
    • the argument list
    • building a Java program
    • name visibility
    • using other components
    • the "static" keyword
    • your first Java program
    • comments & embedded documentation
    • comment documentation
    • syntax
    • embedded HTML
    • @see: referring to other classes
    • class documentation tags
    • variable documentation tags
    • method documentation tags
    • documentation example
    • coding style
    • summary
    • exercises

    Chapter 3: Controlling Program Flow
    (Note: this chapter covers the C aspects of Java, and is primarily a review of C. Since it is assumed that you can read C code before taking the course, this section will not be covered in class. If you are not completely comfortable with C, it's recommended that you read this chapter prior to the course). This chapter begins with all the operators that come to Java from C and C++. In addition, it looks at common operator pitfalls, casting, promotion and precedence. This is followed by the basic control-flow and selection operations that you get with virtually any programming language: choice with if-else; looping with for and while; quitting a loop with break and continue as well as Java's labeled break and labeled continue (which account for the "missing goto" in Java); and selection using switch. Although much of this material has common threads with C and C++ code, there are some differences. In addition, all the examples will be full Java examples so you'll be getting more comfortable with what Java looks like.

    • using Java operators
    • precedence
    • assignment
    • mathematical operators
    • auto increment and decrement
    • relational operators
    • logical operators
    • bitwise operators
    • shift operators
    • ternary if-else operator
    • the comma operator
    • String operator +
    • common pitfalls when using operators
    • casting operators
    • Java has no "sizeof"
    • precedence revisited
    • a compendium of operators
    • execution control
    • true and false
    • if-else
    • iteration
    • do-while
    • for
    • break and continue
    • switch
    • summary
    • exercises

    Chapter 4: Initialization & Cleanup
    This section begins by introducing the constructor to guarantee proper initialization. The definition of the constructor leads into the concept of function overloading (since you may want several constructors). Following that, we'll look at the process of cleanup, which is not always as simple as it seems. Normally you just drop an object when you're done with it and the garbage collector eventually comes along and releases the memory. This portion explores the garbage collector and some of its idiosyncrasies. The section concludes with a closer look at how things are initialized: automatic member initialization, specifying member initialization, the order of initialization, static initialization, and array initialization.

    • guaranteed initialization with the constructor
    • method overloading
    • distinguishing overloaded methods
    • overloading on return values
    • default constructors
    • the this keyword
    • cleanup: finalization and garbage collection
    • what is finalize( ) for?
    • you must perform cleanup
    • member initialization
    • specifying initialization
    • constructor initialization
    • array initialization
    • summary
    • exercises

    Chapter 5: Hiding The Implementation
    This section covers the way that code is packaged together, and how some parts of a library are exposed and other parts are hidden. It begins by looking at the package and import keywords, which perform file-level packaging and allow you to build libraries of classes. The subject of directory paths and file names is examined. The remainder of the section looks at the public, private, and protected keywords and what they mean when used in various contexts.

    • package: the library unit
    • creating unique package names
    • a custom tool library
    • package caveat
    • Java access specifiers
    • "friendly"
    • public: interface access
    • private: you can't touch that!
    • protected: "sort of private"
    • interface & implementation
    • class access
    • summary
    • exercises

    Chapter 6: Reusing Classes
    The concept of inheritance is standard in virtually all OOP languages. It's a way to take an existing class and add to its functionality (as well as change it, the subject of the next section), so inheritance is often a way to re-use code by leaving the "base class" the same, and just patching things here and there to produce what you want. However, inheritance isn't the only way to make new classes from existing ones; you can also embed an object inside your new class with composition. In this section we'll look at these two ways to reuse in Java and how to apply them.

    • composition syntax
    • inheritance syntax
    • initializing the base class
    • combining composition & inheritance
    • guaranteeing proper cleanup
    • name hiding
    • choosing composition vs. inheritance
    • protected
    • incremental development
    • upcasting
    • why "upcasting"?
    • the final keyword
    • final data
    • final methods
    • final classes
    • final caution
    • initialization & class loading
    • initialization with inheritance
    • summary
    • exercises

    Chapter 7: Polymorphism
    On your own, you might take nine months to discover and understand this cornerstone of OOP. Through small, simple examples you'll see how to create a family of types with inheritance and manipulate objects in that family through their common base class. Java's polymorphism allows you to treat all objects in this family generically, which means the bulk of your code doesn't rely on specific type information. This makes your programs extensible, so building programs and code maintenance is easier and cheaper. In addition, Java provides a third way to set up a reuse relationship: through the interface, which is a pure abstraction of the interface of an object. Once you've seen polymorphism, the interface can be clearly understood.

    • upcasting
    • why upcast?
    • the twist
    • method call binding
    • producing the right behavior
    • extensibility
    • overriding vs. overloading
    • abstract classes & methods
    • interfaces
    • "multiple inheritance" in Java
    • extending an interface with inheritance
    • inner classes
    • inner classes and upcasting
    • static inner classes
    • inner classes in methods & scopes
    • the link to the outer class
    • inheriting from inner classes
    • can inner classes be overridden?
    • class identifiers
    • constructors & polymorphism
    • order of constructor calls
    • inheritance and finalize( )
    • behavior of polymorphic methods inside constructors
    • designing with inheritance
    • pure inheritance vs. extension
    • downcasting & run-time type identification
    • summary
    • exercises

    Chapter 8: Holding Your Objects
    It's a fairly simple program that only ever has a fixed quantity of objects with known lifetimes. In general your programs will always be creating new objects at a variety of times that will only be known at the time the program is running. In addition, you won't know until run-time the quantity or even the exact type of the objects you need. To solve the general programming problem, you need to create any number of objects, anytime, anywhere. This section explores in depth the tools that Java supplies to hold objects while you're working with them: the simple arrays and more sophisticated containers (data structures) like Vector and Hashtable.

    • arrays
    • returning an array
    • arrays of primitives
    • containers
    • disadvantage: unknown type
    • enumerators (iterators)
    • types of containers
    • Vector
    • BitSet
    • Stack
    • Hashtable
    • enumerators revisited
    • sorting
    • the Generic Collection Library
    • summary
    • exercises

    Chapter 9: Error Handling With Exceptions
    The basic philosophy of Java is that "badly-formed code will not be run." As much as possible, the compiler catches problems, but sometimes the problems - either programmer error or a natural error condition that occurs as part of the normal execution of the program - can only be detected and dealt with at run-time. Java has exception handling to deal with any problems that arise while the program is running. This section examines how the keywords try, catch, throw, throws, and finally work in Java, when you should throw exceptions, and what to do when you catch them. In addition, you'll see Java's standard exceptions, how to create your own, what happens with exceptions in constructors, and how exception handlers are located.

    • basic exceptions
    • exception arguments
    • catching an exception
    • the try block
    • exception handlers
    • the exception specification
    • catching any exception
    • rethrowing an exception
    • standard Java exceptions
    • exception descriptions
    • the special case of RuntimeException
    • creating your own exceptions
    • exception restrictions
    • performing cleanup with finally
    • what's "finally" for?
    • pitfall: the lost exception
    • constructors
    • exception matching
    • exception guidelines
    • summary
    • exercises

    Chapter 10: The Java IO System
    Supposedly you can divide any program into 3 parts: input, process, and output. This implies that IO (input/output) is a pretty important part of the equation. In this section you'll learn about the different classes that Java provides for reading and writing files, blocks of memory, and the console. The distinction between "old" IO and "new" Java 1.1 IO will be shown. In addition, this section examines the process of taking an object, "streaming" it (so that it can be placed on disk or sent across a network) and reconstructing it, which is handled for you in Java version 1.1.

    • input and output
    • types of InputStream
    • types of OutputStream
    • adding attributes & useful interfaces
    • reading from an InputStream with FilterInputStream
    • writing to a OutputStream with FilterOutputStream
    • off by itself: RandomAccessFile
    • the File class
    • a directory lister
    • checking for and creating directories
    • typical uses of IO streams
    • input streams
    • output streams
    • shorthand for file manipulation
    • reading from standard input
    • piped streams
    • StreamTokenizer
    • StringTokenizer
    • Java 1.1 IO streams
    • sources and sinks of data
    • modifying stream behavior
    • unchanged classes
    • an example
    • redirecting standard IO
    • compression
    • simple compression with GZIP
    • multi-file storage with Zip
    • object serialization
    • controlling serialization
    • summary
    • exercises

    Chapter 11: Run-Time Type Identification
    Run-time type identification (RTTI) lets you find the exact type of an object when you only have a pointer or reference to the base type. Normally, you'll want to intentionally ignore the exact type of an object and let Java's dynamic binding mechanism implement the correct behavior for that type. But occasionally it is very helpful to know the exact type of an object for which you only have a base pointer; often this information allows you to perform a special-case operation more efficiently. This section explains what RTTI is for, how to use it, and how to get rid of it when it doesn't belong there.

    • The need for RTTI
    • the Class object
    • checking before a cast
    • RTTI syntax
    • reflection: run-time class information
    • a class method extractor
    • summary
    • exercises

    Chapter 12: Passing & Returning Objects
    Since the only way you talk to objects in Java is through "handles," the concepts of passing an object into a function, and returning an object from a function, have some interesting consequences. This explains what you need to know to manage objects when you're moving in and out of functions.

    • passing handles around
    • aliasing
    • making local copies
    • pass by value
    • cloning objects
    • adding cloneability to a class
    • successful cloning
    • the effect of Object.clone( )
    • adding cloneability further down a hierarchy
    • why this strange design?
    • controlling cloneability
    • the copy-constructor
    • creating read-only classes
    • the drawback to immutability
    • immutable Strings
    • the String and StringBuffer classes
    • Strings are special
    • summary
    • exercises

    Chapter 13: Creating Windows and Applets
    Java comes with the Abstract Window Toolkit (AWT), which is a set of classes that handle windowing in a portable fashion; these windowing programs can either be applets or stand-alone applications. This chapter is an introduction to the AWT and the creation of World-Wide-Web "applets." We'll also look at pros and cons of the AWT, and the GUI improvements introduced in Java 1.1. Finally, the very important "JavaBeans" technology is introduced, which is fundamental for the creation of Rapid-Application Development (RAD) application building tools.

    • why use the AWT?
    • the basic applet
    • making a Button
    • capturing an event
    • text fields
    • text areas
    • labels
    • check boxes
    • radio buttons
    • drop-down lists
    • list boxes
    • handleEvent( )
    • controlling layout
    • FlowLayout
    • BorderLayout
    • GridLayout
    • CardLayout
    • GridBagLayout
    • alternatives to action()
    • applet restrictions
    • applet advantages
    • windowed applications
    • menus
    • dialog boxes
    • the new AWT
    • the new event model
    • event and listener types
    • making windows and applets with the Java 1.1 AWT
    • revisiting the earlier examples
    • binding events dynamically
    • separating business logic from UI logic
    • recommended coding approaches
    • new Java 1.1 UI APIs
    • desktop colors
    • printing
    • the clipboard
    • visual programming & Beans
    • what is a Bean?
    • extracting BeanInfo with the Introspector
    • a more sophisticated Bean
    • more complex Bean support
    • more to Beans
    • summary
    • exercises

    Chapter 14: Multiple Threads
    Java provides a built-in facility to support multiple concurrent processes running within a single program (unless you have multiple processors on your machine, this is actually the appearance of several processes). Although these can be used anywhere, they are most powerful when trying to create a responsive user interface so, for example, a user isn't prevented from pressing a button or entering data while some processing is going on. This section looks at the syntax and semantics of multithreading in Java.

    • responsive user interfaces
    • inheriting from Thread
    • threading for a responsive interface
    • combining the thread with the main class
    • making many threads
    • daemon threads
    • sharing limited resources
    • improperly accessing resources
    • how Java shares resources
    • JavaBeans revisited
    • blocking
    • becoming blocked
    • deadlock
    • priorities
    • thread groups
    • Runnable revisited
    • too many threads
    • summary
    • exercises

    Chapter 15: Network Programming
    All the Java features and libraries seem to really come together when you start writing programs to work across networks. This chapter explores communication across the Internet, and the classes that Java provides to make this easier. It also covers Java 1.1's Java DataBase Connectivity (JDBC) and Remote Method Invocation (RMI).

    • identifying a machine
    • servers and clients
    • port: a unique place within the machine
    • sockets
    • a simple server and client
    • serving multiple clients
    • datagrams
    • a web application
    • the server application
    • the NameSender applet
    • problems with this approach
    • connecting to databases with JDBC
    • getting the example to work
    • a GUI version of the lookup program
    • why the JDBC API seems so complex
    • remote methods
    • remote interfaces
    • implementing the remote interface
    • creating stubs and skeletons
    • using the remote object
    • alternatives to RMI
    • summary
    • exercises

    Chapter 16: Design patterns
    (Note: ... ...). This chapter introduces the very important and yet non-traditional "patterns" approach to program design. An example of the design evolution process will be studied, starting with an initial solution and moving through the logic and process of evolving the solution to more appropriate designs. You'll see one way that a design can materialize over time.

    • the pattern concept
    • the singleton
    • classifying patterns
    • the observer pattern
    • simulating the trash recycler
    • improving the design
    • "make more objects"
    • a pattern for prototyping creation
    • abstracting usage
    • multiple dispatching
    • implementing the double dispatch
    • the "visitor" pattern
    • RTTI considered harmful?
    • summary
    • exercises

    Chapter 17: Projects
    (Note: ... ...). This chapter includes a set of projects that build on the material presented in this book, or otherwise didn't fit in earlier chapters. These projects are significantly more complex than the examples in the rest of the book, and they often demonstrate new techniques and uses of class libraries.

    • text processing
    • extracting code listings
    • checking capitalization style
    • a method lookup tool
    • complexity theory
    • summary
    • exercises

    Comments from readers:

    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 explainations 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, Sr. Staff Specialist, MCI Telecomunications

    Thank you for "Thinking In Java." It's time someone went beyond mere language description to a thoughtful, penetrating analytic tutorial which 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

    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

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

    Most of the Java books out there are fine for a start, and most just have beginning stuff and a lot of the same exact examples. Yours is by far the best advanced thinking book I've seen. Please publish it soon! ... I also bought "Thinking in C++" just because I was so impressed with "Thinking in Java". - George Laframboise, LightWorx Technology Consulting, Inc.

    I wrote to you earlier about my favorable impressions regarding your Thinking in C++ (a book that stands prominently on my shelf here at work). And today I've been able to delve into Java with your e-book in my virtual hand, and I must say (in my best Chevy Chase from Modern Problems) I like it! Very informative and explanatory, without reading like a dry text book. You cover the most important yet the least covered concepts of Java development - the whys. Sean Brady.

    I've read the first two chapters of TJAVA and I like it a lot. Thanks for writing a great book. The more I read it the better I like it. My students like it, too. Chuck Iverson

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

    Your examples are clear and easy to understand. You took care of many important details of Java, that can't be found easily in the "weak" Java documentation. And you don't waste the reader's time with the basic facts a programmer already knows about. Kai Engert, Innovative Software Germany

    I'm a great fan of your "Thinking in C++" and have recommended it to associates. As I go through the electronic version of your Java book, I'm finding that you've retained the same high level of writing. Thank you! Peter R. Neuwald

    VERY well-written Java book ... think you've done a GREAT job on it. As the leader of a Chicago-area Java special interest group, I've favorably mentioned your book and website several times at our recent meetings. I would like to use "Thinking in Java" as the basis for a part of each monthly SIG meeting, where we review and discuss each chapter in succession. Mark Ertes

    I really appreciate your work and your book is good. I recommend it here to our users and Ph.D. Students. Hugues Leroy // Irisa-Inria Rennes France, Head of Scientific computing and industrial tranfert

    OK, I've only read about 40 pages of Thinking in Java -- but I've already found it the most clearly-written and presented programming book I've come across ... and I'm a writer, myself, so am probably a little critical. I have Thinking in C++ on order and can't wait to crack it -- I'm fairly new to programming and am hitting learning curves head-on, everywhere. So this is just a quick note to say thanks for your excellent work. I had begun to burn a little low on enthusiasm from slogging through the mucky, murky prose of most computer books -- even ones that came with glowing recommendations. I feel a whole lot better now. Glenn Becker Educational Theatre Association

    Thank you for making your wonderful book available. I have found immensely useful in finally understanding what I experienced as confusing in Java and in C++. Reading your book has been very satisfying. Felix Bizaoui, Twin Oaks Industries, Louisa VA

    I must congratulate you on an excellent book. I decided to have a look at Thinking in Java based on my experience with Thinking in C++, and I was not disappointed. Jaco van der Merwe, Software Specialist, DataFusion Systems Ltd, Stellenbosch, South Africa

    This has to be one of the best Java books I've seen. E.F.Pritchard, Senior Software Engineer, Cambridge Animation Systems Ltd., UK.

    ... your book makes all the other Java books I've read or flipped through seem doubly useless and insulting. Brett g Porter, Senior Programmer, Art & Logic

    I have been reading your book for a week or two and compared to the books I have read earlier on Java, your book seems to have given me a great start. I have recommended this book to lot of my friends and they have rated it Excellent. Please accept my congratulations for coming out with an excellent book.Rama Krishna Bhupathi, Software Engineer, TCSI Corporation, San Jose

    Just wanted to say what a "brilliant" piece of work your book is. I've been using it as a major reference for the in-house Java work. I find that the table of contents is just right for quickly locating the section that is required. It's also nice to see a book which is not just a rehash of the API nor treats the programmer like a dummy. Grant Sayer, Java Components Group Leader, Ceedata Systems Pty Ltd, Australia

    Wow! A readable, in-depth Java book. There are a lot of poor (and admittedly a couple of good) Java books out there but from what I've seen yours is definitely one of the best. John Root, Web Developer, Department of Social Security, London

    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.

    I've *just* started Thinking in Java. I expect it to be very good because I really liked Thinking in C++ (which I read as an experienced C++ programmer, trying to stay ahead of the curve). I'm somewhat less experienced in Java, but expect to be very satisfied. You are a wonderful author. Kevin K. Lewis, Technologist, ObjectSpace, Inc.

    I think it's a great book. I learned all I know about Java from this book. Thank you for making it avaliable for free over the Internet. If you wouldn't have I'd know nothing about Java at all. But the best thing is that your book isn't a commercial brouchure for Java. It also shows the bad sides of Java. YOU have done a great job here. Frederik Fix, Belgium

    I have been hooked to your books all the time. A couple of years ago, when I wanted to start with C++, it was "C++ - Inside & Out" which took me around the fascinating world of C++. It helped me in getting better oppurtunities in life. Now, in pursuit of more knowledge and when I wanted to learn Java, I bumped into "Thinking in Java" - No doubts in my mind as to whether I need some other book. Just fantastic. It is more like rediscovering myself as I get along with the book. It is just a month since I started with Java, and heartful thanks to you, I am understanding it better now. Anand Kumar.S - Software Engineer - Computervision (India)

    Your book stands out as an excellent general introduction. Peter Robinson, University of Cambridge Computer Laboratory

    About a month or so ago I discovered your Thinking in Java book. It's by far the best material I have come across to help me learn Java and just wanted you to know how lucky I feel to have found it. THANKS! Chuck Peterson, Product Leader, Internet Product Line, IVIS International

    This is one of the best books I've read about a programming language… Chapter 16 on design patterns is one of the most interesting things I've read for long time. Ilan Finci, graduate student and teaching assistant, Institute of Computer Science, The Hebrew University of Jerusalem, Israel

    The book is great. It's the third book on Java I've started on and I'm about 2/3 of the way through it now. I plan to finish this one. I found out about it because they now use it in some internal classes at Lucent Technologies and a friend told me about the book being on the net. Good work. Jerry Nowlin, MTS, Lucent Technologies

    Of the 6 or so Java books I've accumulated to date, your "Thinking in Java" is by far the best and clearest. Michael Van Waas, Ph.D., President, TMR Associates

    I just want to say thanks for "Thinking in Java", what a wonderful book you've made here! Not to mention downloadable for free! As a student I find your books invaluable (I have a copy of C++ Inside Out, another great book about C++), because they don't only teach me the how-to, but also the whys, which are of course very important in building a strong foundation in languages like C++ or Java. I have quite a lot of friends here who love programming just as I do, and I've told them about your books. They think it's great! Thanks again! P.S.: By the way, I'm an Indonesian and I live in Java. Ray Frederick Djajadinata, Student at Trisakti University, Jakarta

    The mere fact that you have made this work free over the 'net has put me into shock. I thought I'd let you know how much I appreciate and respect what you're doing. Shane LeBouthillier, Computer Engineering student, University of Alberta, Canada

    Home About Books Speaking Training Source Code

     

    Use this form to send your feedback and/or submit a link
    (please, replace sample texts by appropriate data before submitting!)
    From
    your e_mail :
    your URL :
    To Eckel@aol.com ; Bruce@EckelObjects.com ; meurrens@ulb.ac.be ;
    Subject
    Link
    Comment
     

    joodcs home ULB ESP ip-Links La Cambre BeJUG newsletter bibliography proposal

    © Ir. Marc W.F. Meurrens, Brussels, 1997
    First created: July 6, 1997 - Last modified:
    http://www.ulb.ac.be/esp/ip-Links/Java/joodcs/EckelJavaBook.html
    mirror of http://www.EckelObjects.com/javabook.html
    "Revision 9, August 16, 1997" by Bruce Eckel (Bruce@EckelObjects.com)