- preface
- prerequisites
- learning Java
- goals
- chapters
- exercises
- source code
- coding standards
- java versions
- seminars & mentoring
- errors
- acknowledgements
- introduction to objects
- 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++?
- everything is an object
- 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
- controlling program flow
- 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
- initialization & cleanup
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
- hiding the implementation
-
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
- reusing classes
-
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
- polymorphism
-
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
- holding your objects
-
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
- error handling with exceptions
- 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
- the Java IO system
-
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
- run-time type identification
-
The need for RTTI
-
the Class object
-
checking before a cast
-
RTTI syntax
-
reflection: run-time class information
-
a class method extractor
-
summary
-
exercises
- passing and returning objects
-
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
- creating windows and applets
-
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
- multiple threads
-
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
- network programming
-
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
- design patterns
-
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
- projects
-
text processing
-
extracting code listings
-
checking capitalization style
-
a method lookup tool
-
complexity theory
-
summary
-
exercises
- A: using non-Java code
- B: comparing C++ and Java
- C: Java programming
guidelines
- D: a bit about garbage collection
- E: recommended reading