Table of Contents

1 How This Book Teaches You The Java Programming Language

• why you should learn Java
• object-oriented programming languages
• Java's network-oriented features
• programming idioms

2 How to Compile and Execute a Simple Program

• compiling and executing
• class and method definitions
• the display statement and strings
• case sensitivity and blank insensitivity
• operators and operands
• the main method

3 How to Declare Variables

• integral and floating-point data types
• variable declarations, initialization, and assignment
• short and long comments

4 How to Write Arithmetic Expressions

• arithmetic expressions
• precedence and association
• binary and unary operators
• type casting

5 How to Define Simple Methods

• calling and returning from methods
• arguments, parameters, and values
• method overloading in multiple classes
• method overloading in one class

6 How to Understand Variable Scope and Extent

• parameters and local variables
• local scope and dynamic extent
• blocks

7 How to Benefit from Procedure Abstraction

• making programs easier to reuse, read, and debug
• making programs easier to augment, improve, and adapt

8 How to Declare Class Variables

• class variables
• final variables

9 How to Create Class Instances

• instance creation
• instance variables

10 How to Define Instance Methods

• defining instance methods
• the target argument
• the this parameter

11 How to Define Constructors

• constructors and initialization
• the default constructor
• constructors with parameters

12 How to Define Getter and Setter Methods

• getter and setter instance methods
• imaginary instance variables

13 How to Benefit from Data Abstraction

• access methods and data abstraction
• making programs easier to reuse

14 How to Define Classes that Inherit Instance Variables and Methods

• subclasses and superclasses
• instance-variable and instance-method inheritance
• drawing a class-hierarchy diagram
• superclass constructor evaluation
• shadowing, also known as overriding

15 How to Enforce Abstraction Using Protected and Private Variables and Methods

• private instance variables and instance methods
• enforcing data abstraction
• public instance variable and methods
• private instance variable and methods
• protected instance variable and methods
• the public interface

16 How to Write Constructors that Call Other Constructors

• using this to call a constructor
• using super to call a constructor

17 How to Write Methods that Call Other Methods

• implicit method targets
• the this parameter as a method target
• the super parameter as a method target

18 How to Design Classes and Class Hierarchies

• explicit representation
• the no-duplication principle
• the look-it-up principle
• the need-to-know principle
• the is-a versus has-a principle

19 How to Enforce Requirements Using Abstract Classes and Abstract Methods

• abstract classes and abstract methods
• imposing method-definition requirements with abstract classes
• classes without instances
• classes without subclasses

20 How to Enforce Requirements and to Document Programs Using Interfaces

• defining interfaces
• imposing method-definition requirements with interfaces
• interfaces as documentation centers
• interfaces as an alternative to multiple inheritance

21 How to Perform Tests Using Predicates

• predicates and Boolean values
• equal, ==, and not equal, !=
• greater than, >, and less than, <
• not, !
• casting before testing

22 How to Write Conditional Statements

• Boolean expressions
if and if--else statements
• empty statements
• the conditional operator, ?:

23 How to Combine Boolean Expressions

• and, &&, and or, ||
• evaluation order

24 How to Write Iteration Statements

while and for statements
• augmented assignment operators
• increment, ++, and decrement, --, operators
• side effects and evaluation order

25 How to Write Recursive Methods

• recursive methods
• the base part and the recursive part
• efficiency considerations

26 How to Write Multiway Conditional Statements

switch statements
case and default
• fall through

27 How to Work with File Input Streams

• creating file input streams
• creating input-stream readers
• creating tokenizers
• stepping, testing, and reading from tokenizers

28 How to Create and Access Arrays

• declaring and initializing arrays
• arrays of numeric elements
• arrays of class-instance elements
• arrays of mixed instance types

29 How to Move Arrays into and out of Methods

• using arrays as arguments
• returning arrays from methods

30 How to Store Data in Expandable Vectors

• storing and retrieving elements in vectors
• obtaining the size of a vector
• queues and push-down lists
• casting vector elements prior to use
• vector iteration and iterators
• wrappers

31 How to Work With Characters and Strings

• characters and strings
• extracting characters from strings
• using characters in switch statements

32 How to Catch Exceptions

• exception handling
• the try statement
catch and finally blocks
exit statements

33 How to Work with Output File Streams

• creating file output streams
• creating output-stream print writers
• printing to print writers

34 How to Write and Read Values Using the Serializable Interface

• reading and writing serialized files
• using the Serializable interface to instruct the compiler

35 How to Modularize Programs Using Compilation Units and Packages

• modularity
• grouping classes into modular compilation units
• grouping classes into modular packages
• package names and path names

36 How to Combine Private Variables and Methods with Packages

• private package and compilation unit access
• protected package and compilation unit access
• public package and compilation unit access
• unmarked package and compilation unit access

37 How to Create Windows and to Activate Listeners

• graphical user interfaces
• components, containers, and windows
• events and listeners

38 How to Define Inner Classes and to Structure Applications

• inner classes
• nameless inner classes
• application structure

39 How to Draw Lines in Windows

• graphics contexts
• drawing lines
• content panes

40 How to Write Text in Windows

• writing text
• fonts and font metrics

41 How to Use the Model--View Approach to GUI Design

• the Observable class
• the Observer interface
• notifying and updating

42 How to Define Standalone Observers and Listeners

• accessing applications from observers and listeners
• accessing application variables from observers and listeners

43 How to Define Applets

• applets and the JApplet class
• the role of applets in browsers
init, start, stop, and destroy methods
• testing applets

44 How to Access Applets from Web Browsers

• formatting tags
• embedding applets in HTML files
• locating HTML files with URL addresses

45 How to Use Resource Locators

• accessing text and image files
• the Class class
• location-independent resource access
• security features

46 How to Use Choice Lists to Select Instances

• adding elements to choice lists
• determining which element has been selected

47 How to Bring Images into Applets

• drawing images
• scaling images

48 How to Use Threads to Implement Dynamic Applets

• apparently simultaneous computation
• processes and multithreading
• starting and stopping threads
• putting a thread to sleep

49 How to Create Forms and to Fire Your own Events

• labels, text fields, and buttons
• using the grid layout
• property-change events and listeners

50 How to Display Menus and Dialog Windows

• menu bars, menus, and menu items
• popup menus and menu items

51 How to Develop Your Own Layout Manager

• how layout managers do their work
• laying out containers without a layout manager
• defining new layout managers

52 How to Implement Dynamic Tables

• tables and table models
• using renderers to change appearance
• row selection and cell editing

53 How to Activate Remote Computations

• clients and servers
• calling methods to be run on servers
• compiling remotely accessible classes

54 How to Collect Information Using Servlets

• link-activated servlets
• form-activated servlets
• servlet-generated HTML pages
• cookies

55 How to Construct JAR files for Program Distribution

• creating JAR files
• running applications from JAR files
• manifest files

A Operator Precedence

B The Meter Canvas

C Applet Parameters

D The Swing Classes

E Layout Managers

F The Graphics2D Package



Other Books