Thinking in Java, 3rd ed. Revision 4.0

This book is a case in point. A majority of folks thought I was very bold or a little crazy to put the entire thing up on
the Web. “Why would anyone buy it?” they asked. If I had been of a more conservative nature I wouldn’t have done
it, but I really didn’t want to write another computer book in the same old way. I didn’t know what would happen but
it turned out to be the smartest thing I’ve ever done with a book. 

More PDF Content

Thinking in Java, 3rd ed. Revision 4.0
1 – Introduction to Objects
1.1 – The progress of abstraction
1.2 – An object has an interface
1.3 – An object provides services
1.4 – The hidden implementation
1.5 – Reusing the implementation
1.6 – Inheritance: reusing the interface
1.6.1 – Is-a vs. is-like-a relationships
1.7 – Interchangeable objects with polymorphism
1.7.1 – Abstract base classes and interfaces
1.8 – Object creation, use & lifetimes
1.8.1 – Collections and iterators
1.8.2 – The singly rooted hierarchy
1.8.3 – Downcasting vs. templates/generics
1.8.4 – Ensuring proper cleanup
1.8.5 – Garbage collectors vs. efficiency and flexibility
1.9 – Exception handling: dealing with errors
1.10 – Concurrency
1.11 – Persistence
1.12 – Java and the Internet
1.12.1 – What is the Web?
1.12.1.1 – Client/Server computing
1.12.1.2 – The Web as a giant server
1.12.2 – Client-side programming
1.12.2.1 – Plug-ins
1.12.2.2 – Scripting languages
1.12.2.3 – Java
1.12.2.4 – .NET and C#
1.12.2.5 – Security
1.12.2.6 – Internet vs. intranet
1.12.3 – Server-side programming
1.12.4 – Applications
1.13 – Why Java succeeds
1.13.1 – Systems are easier to express and understand
1.13.2 – Maximal leverage with libraries
1.13.3 – Error handling
1.13.4 – Programming in the large
1.14 – Java vs. C++?
1.15 – Summary
2 – Everything is an Object
2.1 – You manipulate objects with references
2.2 – You must create all the objects
2.2.1 – Where storage lives
2.2.2 – Special case: primitive types
2.2.2.1 – High-precision numbers
2.2.3 – Arrays in Java
2.3 – You never need to destroy an object
2.3.1 – Scoping
2.3.2 – Scope of objects
2.4 – Creating new data types: class
2.4.1 – Fields and methods
2.4.1.1 – Default values for primitive members
2.5 – Methods, arguments, and return values
2.5.1 – The argument list
2.6 – Building a Java program
2.6.1 – Name visibility
2.6.2 – Using other components
2.6.3 – The static keyword
2.7 – Your first Java program
2.7.1 – Compiling and running
2.8 – Comments and embedded documentation
2.8.1 – Comment documentation
2.8.2 – Syntax
2.8.3 – Embedded HTML
2.8.4 – Some example tags
2.8.4.1 – @see: referring to other classes
2.8.4.2 – {@link package.class#member label}
2.8.4.3 – {@docRoot}
2.8.4.4 – {@inheritDoc}
2.8.4.5 – @version
2.8.4.6 – @author
2.8.4.7 – @since
2.8.4.8 – @param
2.8.4.9 – @return
2.8.4.10 – @throws
2.8.4.11 – @deprecated
2.8.5 – Documentation example
2.9 – Coding style
2.10 – Summary
2.11 – Exercises
3 – Controlling Program Flow
3.1 – Using Java operators
3.1.1 – Precedence
3.1.2 – Assignment
3.1.2.1 – Aliasing during method calls
3.1.3 – Mathematical operators
3.1.3.1 – Regular expressions
3.1.3.2 – Unary minus and plus operators
3.1.4 – Auto increment and decrement
3.1.5 – Relational operators
3.1.5.1 – Testing object equivalence
3.1.6 – Logical operators
3.1.6.1 – Short-circuiting
3.1.7 – Bitwise operators
3.1.8 – Shift operators
3.1.9 – Ternary if-else operator
3.1.10 – The comma operator
3.1.11 – String operator +
3.1.12 – Common pitfalls when using operators
3.1.13 – Casting operators
3.1.13.1 – Literals
3.1.13.2 – Promotion
3.1.14 – Java has no \”sizeof\”
3.1.15 – Precedence revisited
3.1.16 – A compendium of operators
3.2 – Execution control
3.2.1 – true and false
3.2.2 – if-else
3.2.3 – return
3.2.4 – Iteration
3.2.5 – do-while
3.2.6 – for
3.2.6.1 – The comma operator
3.2.7 – break and continue
3.2.7.1 – The infamous \”goto\”
3.2.8 – switch
3.2.8.1 – Calculation details
3.3 – Summary
3.4 – Exercises
4 – Initialization & Cleanup
4.1 – Guaranteed initialization with the constructor
4.2 – Method overloading
4.2.1 – Distinguishing overloaded methods
4.2.2 – Overloading with primitives
4.2.3 – Overloading on return values
4.2.4 – Default constructors
4.2.5 – The this keyword
4.2.5.1 – Calling constructors from constructors
4.2.5.2 – The meaning of static
4.3 – Cleanup: finalization and garbage collection
4.3.1 – What is finalize( ) for?
4.3.2 – You must perform cleanup
4.3.3 – The termination condition
4.3.4 – How a garbage collector works
4.4 – Member initialization
4.4.1 – Specifying initialization
4.4.2 – Constructor initialization
4.4.2.1 – Order of initialization
4.4.2.2 – Static data initialization
4.4.2.3 – Explicit static initialization
4.4.2.4 – Non-static instance initialization
4.5 – Array initialization
4.5.1 – Multidimensional arrays
4.6 – Summary
4.7 – Exercises
5 – Hiding the Implementation
5.1 – package: the library unit
5.1.1 – Creating unique package names
5.1.1.1 – Collisions
5.1.2 – A custom tool library
5.1.3 – Using imports to change behavior
5.1.4 – Package caveat
5.2 – Java access specifiers
5.2.1 – Package access
5.2.2 – public: interface access
5.2.2.1 – The default package
5.2.3 – private: you can\’t touch that!
5.2.4 – protected: inheritance access
5.3 – Interface and implementation
5.4 – Class access
5.5 – Summary
5.6 – Exercises
6 – Reusing Classes
6.1 – Composition syntax
6.2 – Inheritance syntax
6.2.1 – Initializing the base class
6.2.1.1 – Constructors with arguments
6.2.1.2 – Catching base constructor exceptions
6.3 – Combining composition and inheritance
6.3.1 – Guaranteeing proper cleanup
6.3.2 – Name hiding
6.4 – Choosing composition vs. inheritance
6.5 – protected
6.6 – Incremental development
6.7 – Upcasting
6.7.1 – Why \”upcasting\”?
6.7.1.1 – Composition vs. inheritance revisited
6.8 – The final keyword
6.8.1 – Final data
6.8.1.1 – Blank finals
6.8.1.2 – Final arguments
6.8.2 – Final methods
6.8.2.1 – final and private
6.8.3 – Final classes
6.8.4 – Final caution
6.9 – Initialization and class loading
6.9.1 – Initialization with inheritance
6.10 – Summary
6.11 – Exercises
7 – Polymorphism
7.1 – Upcasting revisited
7.1.1 – Forgetting the object type
7.2 – The twist
7.2.1 – Method-call binding
7.2.2 – Producing the right behavior
7.2.3 – Extensibility
7.2.4 – Pitfall: \”overriding\” private methods
7.3 – Abstract classes and methods
7.4 – Constructors and polymorphism
7.4.1 – Order of constructor calls
7.4.2 – Inheritance and cleanup
7.4.3 – Behavior of polymorphic methods inside constructors
7.5 – Designing with inheritance
7.5.1 – Pure inheritance vs. extension
7.5.2 – Downcasting and run-time type identification
7.6 – Summary
7.7 – Exercises
8 – Interfaces & Inner Classes
8.1 – Interfaces
8.1.1 – \”Multiple inheritance\” in Java
8.1.1.1 – Name collisions when combining interfaces
8.1.2 – Extending an interface with inheritance
8.1.3 – Grouping constants
8.1.4 – Initializing fields in interfaces
8.1.5 – Nesting interfaces
8.2 – Inner classes
8.2.1 – Inner classes and upcasting
8.2.2 – Inner classes in methods and scopes
8.2.3 – Anonymous inner classes
8.2.4 – The link to the outer class
8.2.5 – Nested classes
8.2.6 – Referring to the outer class object
8.2.7 – Reaching outward from a multiply-nested class
8.2.8 – Inheriting from inner classes
8.2.9 – Can inner classes be overridden?
8.2.10 – Local inner classes
8.2.11 – Inner class identifiers
8.3 – Why inner classes?
8.3.1 – Closures & Callbacks
8.3.2 – Inner classes & control frameworks
8.4 – Summary
8.5 – Exercises
9 – Error Handling with Exceptions
9.1 – Basic exceptions
9.1.1 – Exception arguments
9.2 – Catching an exception
9.2.1 – The try block
9.2.2 – Exception handlers
9.2.2.1 – Termination vs. resumption
9.3 – Creating your own exceptions
9.4 – The exception specification
9.5 – Catching any exception
9.5.1 – Rethrowing an exception
9.5.2 – Exception chaining
9.6 – Standard Java exceptions
9.6.1 – The special case of RuntimeException
9.7 – Performing cleanup with finally
9.7.1 – What\’s finally for?
9.7.2 – Pitfall: the lost exception
9.8 – Exception restrictions
9.9 – Constructors
9.10 – Exception matching
9.11 – Alternative approaches
9.11.1 – History
9.11.2 – Perspectives
9.11.3 – Passing exceptions to the console
9.11.4 – Converting checked to unchecked exceptions
9.12 – Exception guidelines
9.13 – Summary
9.14 – Exercises
10 – Detecting Types
10.1 – The need for RTTI
10.1.1 – The Class object
10.1.1.1 – Class literals
10.1.2 – Checking before a cast
10.1.2.1 – Using class literals
10.1.2.2 – A dynamic instanceof
10.1.2.3 – instanceof vs. Class equivalence
10.2 – RTTI syntax
10.3 – Reflection: run time class information
10.3.1 – A class method extractor
10.4 – Summary
10.5 – Exercises
11 – Collections of Objects
11.1 – Arrays
11.1.1 – Arrays are first-class objects
11.1.1.1 – Containers of primitives
11.1.2 – Returning an array
11.1.3 – The Arrays class
11.1.4 – Filling an array
11.1.5 – Copying an array
11.1.6 – Comparing arrays
11.1.7 – Array element comparisons
11.1.8 – Sorting an array
11.1.9 – Searching a sorted array
11.1.10 – Array summary
11.2 – Introduction to containers
11.2.1 – Printing containers
11.2.2 – Filling containers
11.3 – Container disadvantage: unknown type
11.3.1 – Sometimes it works anyway
11.3.2 – Making a type-conscious ArrayList
11.3.2.1 – Parameterized types
11.4 – Iterators
11.4.1 – Unintended recursion
11.5 – Container taxonomy
11.6 – Collection functionality
11.7 – List functionality
11.7.1 – Making a stack from a LinkedList
11.7.2 – Making a queue from a LinkedList
11.8 – Set functionality
11.8.1 – SortedSet
11.9 – Map functionality
11.9.1 – SortedMap
11.9.2 – LinkedHashMap
11.9.3 – Hashing and hash codes
11.9.3.1 – Understanding hashCode( )
11.9.3.2 – HashMap performance factors
11.9.4 – Overriding hashCode( )
11.10 – Holding references
11.10.1 – The WeakHashMap
11.11 – Iterators revisited
11.12 – Choosing an implementation
11.12.1 – Choosing between Lists
11.12.2 – Choosing between Sets
11.12.3 – Choosing between Maps
11.13 – Sorting and searching Lists
11.14 – Utilities
11.14.1 – Making a Collection or Map unmodifiable
11.14.2 – Synchronizing a Collection or Map
11.14.2.1 – Fail fast
11.15 – Unsupported operations
11.16 – Java 1.0/1.1 containers
11.16.1 – Vector & Enumeration
11.16.2 – Hashtable
11.16.3 – Stack
11.16.4 – BitSet
11.17 – Summary
11.18 – Exercises
12 – The Java I/O System
12.1 – The File class
12.1.1 – A directory lister
12.1.1.1 – Anonymous inner classes
12.1.2 – Checking for and creating directories
12.2 – Input and output
12.2.1 – Types of InputStream
12.2.2 – Types of OutputStream
12.3 – Adding attributes and useful interfaces
12.3.1 – Reading from an InputStream with FilterInputStream
12.3.2 – Writing to an OutputStream with FilterOutputStream
12.4 – Readers & Writers
12.4.1 – Sources and sinks of data
12.4.2 – Modifying stream behavior
12.4.3 – Unchanged Classes
12.5 – Off by itself: RandomAccessFile
12.6 – Typical uses of I/O streams
12.6.1 – Input streams
12.6.1.1 – Buffered input file (1)
12.6.1.2 – Input from memory (2)
12.6.1.3 – Formatted memory input (3)
12.6.1.4 – File output (4)
12.6.2 – Output streams
12.6.2.1 – Storing and recovering data (5)
12.6.2.2 – Reading and writing random access files (6)
12.6.3 – Piped streams
12.7 – File reading & writing utilities
12.8 – Standard I/O
12.8.1 – Reading from standard input
12.8.2 – Changing System.out to a PrintWriter
12.8.3 – Redirecting standard I/O
12.9 – New I/O
12.9.1 – Converting data
12.9.2 – Fetching primitives
12.9.3 – View buffers
12.9.3.1 – Endians
12.9.4 – Data manipulation with buffers
12.9.5 – Buffer details
12.9.6 – Memory-mapped files
12.9.6.1 – Performance
12.9.7 – File locking
12.9.7.1 – Locking portions of a mapped file
12.10 – Compression
12.10.1 – Simple compression with GZIP
12.10.2 – Multifile storage with Zip
12.10.3 – Java ARchives (JARs)
12.11 – Object serialization
12.11.1 – Finding the class
12.11.2 – Controlling serialization
12.11.2.1 – The transient keyword
12.11.2.2 – An alternative to Externalizable
12.11.2.3 – Versioning
12.11.3 – Using persistence
12.12 – Preferences
12.13 – Regular expressions
12.13.1 – Creating regular expressions
12.13.2 – Quantifiers
12.13.2.1 – CharSequence
12.13.3 – Pattern and Matcher
12.13.3.1 – find( )
12.13.3.2 – Groups
12.13.3.3 – start( ) and end( )
12.13.3.4 – Pattern flags
12.13.4 – split( )
12.13.5 – Replace operations
12.13.6 – reset( )
12.13.7 – Regular expressions and Java I/O
12.13.8 – Is StringTokenizer needed?
12.14 – Summary
12.15 – Exercises
13 – Concurrency
13.1 – Motivation
13.2 – Basic threads
13.2.1 – Yielding
13.2.2 – Sleeping
13.2.3 – Priority
13.2.4 – Daemon threads
13.2.5 – Joining a thread
13.2.6 – Coding variations
13.2.7 – Creating responsive user interfaces
13.3 – Sharing limited resources
13.3.1 – Improperly accessing resources
13.3.1.1 – A resource testing framework
13.3.2 – Colliding over resources
13.3.3 – Resolving shared resource contention
13.3.3.1 – Synchronizing the EvenGenerator
13.3.3.2 – Atomic operations
13.3.3.3 – Fixing Semaphore
13.3.4 – Critical sections
13.4 – Thread states
13.4.1 – Becoming blocked
13.5 – Cooperation between threads
13.5.1 – Wait and notify
13.5.2 – Using Pipes for I/O between threads
13.5.3 – More sophisticated cooperation
13.6 – Deadlock
13.7 – The proper way to stop
13.8 – Interrupting a blocked thread
13.9 – Thread groups
13.10 – Summary
13.11 – Exercises
14 – Creating Windows & Applets
14.1 – The basic applet
14.1.1 – Applet restrictions
14.1.2 – Applet advantages
14.1.3 – Application frameworks
14.1.4 – Running applets inside a Web browser
14.1.5 – Using Appletviewer
14.1.6 – Testing applets
14.2 – Running applets from the command line
14.2.1 – A display framework
14.3 – Making a button
14.4 – Capturing an event
14.5 – Text areas
14.6 – Controlling layout
14.6.1 – BorderLayout
14.6.2 – FlowLayout
14.6.3 – GridLayout
14.6.4 – GridBagLayout
14.6.5 – Absolute positioning
14.6.6 – BoxLayout
14.6.7 – The best approach?
14.7 – The Swing event model
14.7.1 – Event and listener types
14.7.1.1 – Using listener adapters for simplicity
14.7.2 – Tracking multiple events
14.8 – A catalog of Swing components
14.8.1 – Buttons
14.8.1.1 – Button groups
14.8.2 – Icons
14.8.3 – Tool tips
14.8.4 – Text fields
14.8.5 – Borders
14.8.6 – JScrollPanes
14.8.7 – A mini-editor
14.8.8 – Check boxes
14.8.9 – Radio buttons
14.8.10 – Combo boxes (drop-down lists)
14.8.11 – List boxes
14.8.12 – Tabbed panes
14.8.13 – Message boxes
14.8.14 – Menus
14.8.15 – Pop-up menus
14.8.16 – Drawing
14.8.17 – Dialog Boxes
14.8.18 – File dialogs
14.8.19 – HTML on Swing components
14.8.20 – Sliders and progress bars
14.8.21 – Trees
14.8.22 – Tables
14.8.23 – Selecting Look & Feel
14.8.24 – The clipboard
14.9 – Packaging an applet into a JAR file
14.10 – Signing applets
14.11 – JNLP and Java Web Start
14.12 – Programming techniques
14.12.1 – Binding events dynamically
14.12.2 – Separating business logic from UI logic
14.12.3 – A canonical form
14.13 – Concurrency & Swing
14.13.1 – Runnable revisited
14.13.2 – Managing concurrency
14.14 – Visual programming and JavaBeans
14.14.1 – What is a JavaBean?
14.14.2 – Extracting BeanInfo with the Introspector
14.14.3 – A more sophisticated Bean
14.14.4 – JavaBeans and synchronization
14.14.5 – Packaging a Bean
14.14.6 – More complex Bean support
14.14.7 – More to Beans
14.15 – Summary
14.16 – Exercises
15 – Discovering Problems
15.1 – Unit Testing
15.1.1 – A Simple Testing Framework
15.1.2 – JUnit
15.2 – Improving reliability with assertions
15.2.1 – Assertion syntax
15.2.2 – Using Assertions for Design by Contract
15.2.2.1 – Check instructions
15.2.2.2 – Preconditions
15.2.2.3 – Postconditions
15.2.2.4 – Invariants
15.2.2.5 – Relaxing DBC
15.2.3 – Example: DBC + white-box unit testing
15.3 – Building with Ant
15.3.1 – Automate everything
15.3.2 – Problems with make
15.3.3 – Ant: the defacto standard
15.3.3.1 – Ant extensions
15.3.4 – Version control with CVS
15.3.5 – Daily builds
15.4 – Logging
15.4.1 – Logging Levels
15.4.2 – LogRecords
15.4.3 – Handlers
15.4.3.1 – Multiple Handlers
15.4.3.2 – Writing your own Handlers
15.4.4 – Filters
15.4.5 – Formatters
15.4.6 – Example: Sending email to report log messages
15.4.7 – Controlling Logging Levels through Namespaces
15.4.8 – Logging Practices for Large Projects
15.4.8.1 – Configuration files
15.4.8.2 – Rotating log files
15.4.8.3 – Suggested practices
15.4.9 – Summary
15.5 – Debugging
15.5.1 – Debugging with JDB
15.5.2 – Graphical debuggers
15.6 – Profiling and optimizing
15.6.1 – Tracking memory consumption
15.6.2 – Tracking CPU usage
15.6.3 – Coverage testing
15.6.4 – JVM Profiling Interface
15.6.5 – Using HPROF
15.6.6 – Thread performance
15.6.7 – Optimization guidelines
15.7 – Doclets
15.8 – Summary
15.9 – Exercises
16 – Analysis and Design
16.1 – Methodology
16.2 – Phase 0: Make a plan
16.2.1 – The mission statement
16.3 – Phase 1: What are we making?
16.4 – Phase 2: How will we build it?
16.4.1 – Five stages of object design
16.4.2 – Guidelines for object development
16.5 – Phase 3: Build the core
16.6 – Phase 4: Iterate the use cases
16.7 – Phase 5: Evolution
16.8 – Plans pay off
16.9 – Extreme Programming
16.9.1 – Write tests first
16.9.2 – Pair programming
16.10 – Strategies for transition
16.10.1 – Guidelines
16.10.1.1 – 1. Training
16.10.1.2 – 2. Low-risk project
16.10.1.3 – 3. Model from success
16.10.1.4 – 4. Use existing class libraries
16.10.1.5 – 5. Don\’t rewrite existing code in Java
16.10.2 – Management obstacles
16.10.2.1 – Startup costs
16.10.2.2 – Performance issues
16.10.2.3 – Common design errors
16.11 – Summary
A – Passing & Returning Objects
A.1 – Passing references around
A.1.1 – Aliasing
A.2 – Making local copies
A.2.1 – Pass by value
A.2.2 – Cloning objects
A.2.3 – Adding cloneability to a class
A.2.3.1 – Using a trick with protected
A.2.3.2 – Implementing the Cloneable interface
A.2.4 – Successful cloning
A.2.5 – The effect of Object.clone( )
A.2.6 – Cloning a composed object
A.2.7 – A deep copy with ArrayList
A.2.8 – Deep copy via serialization
A.2.9 – Adding cloneability farther down a hierarchy
A.2.10 – Why this strange design?
A.3 – Controlling cloneability
A.3.1 – The copy constructor
A.3.1.1 – Why does it work in C++ and not Java?
A.4 – Read-only classes
A.4.1 – Creating read-only classes
A.4.2 – The drawback to immutability
A.4.3 – Immutable Strings
A.4.3.1 – Implicit constants
A.4.3.2 – Overloading \’+\’ and the StringBuffer
A.4.4 – The String and StringBuffer classes
A.4.5 – Strings are special
A.5 – Summary
A.6 – Exercises
A.7 – Appendix
B – Java Programming Guidelines
B.1 – Design
B.2 – Implementation
C – Supplements
C.1 – Foundations for Java seminar-on-CD
C.2 – Thinking in Java seminar
C.3 – Hands-On Java seminar-on-CD 3rd edition
C.4 – Designing Objects & Systems seminar
C.5 – Thinking in Enterprise Java
C.6 – The J2EE seminar
C.7 – Thinking in Patterns (with Java)
C.8 – Thinking in Patterns seminar
C.9 – Design consulting and reviews
D – Resources
D.1 – Software
D.2 – Books
D.2.1 – Analysis & design
D.2.2 – Python
D.2.3 – My own list of books
E – Index

Download Thinking in Java, 3rd ed. Revision 4.0 pdf from ftp-developpez.com, 711 pages, 4718.95KB.
Related Books

Leave a Reply