| |
| |
Getting Started | |
| |
| |
The HelloWeb Applet | |
| |
| |
What Is Java? | |
| |
| |
Java Is a Programming Language | |
| |
| |
Java Is Platform Independent | |
| |
| |
Java Is Object Oriented | |
| |
| |
Classes and Objects | |
| |
| |
Attributes and Methods | |
| |
| |
Why Learn Java? | |
| |
| |
Pathways to Learning Java | |
| |
| |
Where to Start | |
| |
| |
Installing and Setting Up the JDK | |
| |
| |
Accessing the Sun Site | |
| |
| |
The JDK Installation Executable | |
| |
| |
Starting Your Windows Installation | |
| |
| |
Windows Installation and Setup Continued | |
| |
| |
Verifying and Copying the Path to Your JRE | |
| |
| |
Setting the Path Variable | |
| |
| |
Writing Your First Program | |
| |
| |
Setting Up to Work with DOS | |
| |
| |
DOS Commands | |
| |
| |
Creating a Hello World Program | |
| |
| |
HelloWorld Syntax Basics | |
| |
| |
Compiling the Hello World Program | |
| |
| |
Running the Hello World Program | |
| |
| |
Writing Your First Applet | |
| |
| |
Applet Code | |
| |
| |
Compiling the Applet Code | |
| |
| |
Writing an HTML File for an Applet | |
| |
| |
Using the Applet Viewer | |
| |
| |
Running Your Applet in the Browser | |
| |
| |
Summary | |
| |
| |
Variables, Data Types, and Simple IO | |
| |
| |
The Name Game Application | |
| |
| |
Variables and Data Types | |
| |
| |
Primitive Data Types | |
| |
| |
Understanding Literals | |
| |
| |
Casting and Type Promotion | |
| |
| |
Strings and Character Escape Codes | |
| |
| |
Naming Variables | |
| |
| |
Conventions | |
| |
| |
Assignment and Initialization | |
| |
| |
Working with Numbers | |
| |
| |
Operators and Operands | |
| |
| |
How to Do Math | |
| |
| |
The TipAdder Program | |
| |
| |
Formatting Decimal Precision | |
| |
| |
Operator Precedence | |
| |
| |
Getting User Input | |
| |
| |
The BufferedReader Class | |
| |
| |
The try...catch Block | |
| |
| |
Parsing Strings to Numbers | |
| |
| |
Accepting Command-Line Arguments | |
| |
| |
Strings and String Operations | |
| |
| |
The Name Game | |
| |
| |
Summary | |
| |
| |
The Fortune Teller: Random Numbers, Conditions, and Arrays | |
| |
| |
The Fortune Teller Application | |
| |
| |
Generating Random Numbers | |
| |
| |
The Math Class | |
| |
| |
The Random Class | |
| |
| |
Generating Different Types of Random Numbers | |
| |
| |
Seeding Values | |
| |
| |
More of the Math Class | |
| |
| |
Flow and Selection | |
| |
| |
Conditions and Conditional Operators | |
| |
| |
Single-Entry Selection | |
| |
| |
The Ternary Operator | |
| |
| |
Boolean Operators | |
| |
| |
The if...else Statement | |
| |
| |
The Temperature Conversion Program | |
| |
| |
The if...else if...else Statement | |
| |
| |
The switch Structure | |
| |
| |
The Dice Roller Program | |
| |
| |
Arrays | |
| |
| |
Declaring Arrays | |
| |
| |
Assigning Values to Arrays | |
| |
| |
Combined Declaration and Initialization | |
| |
| |
Accessing Array Values | |
| |
| |
The Array Use Program | |
| |
| |
The Fortune Teller Revisited | |
| |
| |
Summary | |
| |
| |
Repetition Statements and Exception Handling | |
| |
| |
The Guess-a-Number Application | |
| |
| |
Flow as Repetition | |
| |
| |
The for Statement | |
| |
| |
The Racer Program | |
| |
| |
Basic Repetition Activities | |
| |
| |
Redefinition of Control Variables | |
| |
| |
Control and Unary Operators | |
| |
| |
Variations on Intervals | |
| |
| |
Compound Assignment Operators | |
| |
| |
Variations on the Use of the for Structure | |
| |
| |
Nested Repetition Blocks | |
| |
| |
The while Statement | |
| |
| |
The do...while Statement | |
| |
| |
The continue and break Keywords | |
| |
| |
Using throw and finally with try...catch Structures | |
| |
| |
Back to Guessing a Number | |
| |
| |
Summary | |
| |
| |
Object-Oriented Programming | |
| |
| |
Object-Oriented Concepts | |
| |
| |
States and Attributes | |
| |
| |
Behaviors | |
| |
| |
Attributes and Methods | |
| |
| |
Picturing Classes | |
| |
| |
Implementing a Class | |
| |
| |
Defining Attributes | |
| |
| |
Defining Methods | |
| |
| |
Default Constructors | |
| |
| |
Overloaded Constructors | |
| |
| |
Creating a Test Driver Class | |
| |
| |
Encapsulation | |
| |
| |
Scope Considerations | |
| |
| |
The Scope and ScopeTest Classes | |
| |
| |
More on Methods | |
| |
| |
Method Overloading | |
| |
| |
Method Signatures and Return Operations | |
| |
| |
Assignments and Cascading Calls | |
| |
| |
Points of Return | |
| |
| |
Static Methods and Attributes | |
| |
| |
More on Constructors and the this Keyword | |
| |
| |
Composition | |
| |
| |
The Card Class | |
| |
| |
The CardDeck Class | |
| |
| |
Testing the Associated Classes | |
| |
| |
Trump | |
| |
| |
Summary | |
| |
| |
Building a Class Hierarchy | |
| |
| |
Software Reusability | |
| |
| |
Specialization and Generalization | |
| |
| |
Creating a Class Hierarchy | |
| |
| |
Concrete Classes | |
| |
| |
A Concrete Base Class | |
| |
| |
Testing the Base Car Class | |
| |
| |
Second-Tier Classes | |
| |
| |
Third-Tier Classes | |
| |
| |
Method Overriding | |
| |
| |
The Sedan Class and Overriding | |
| |
| |
Testing the Sedan Class | |
| |
| |
Finalization | |
| |
| |
Polymorphism | |
| |
| |
ChildCart | |
| |
| |
DieselElectric | |
| |
| |
GasElectric | |
| |
| |
Using Polymorphic Options | |
| |
| |
Summary | |
| |
| |
Abstract Classes and Interfaces | |
| |
| |
Abstract Classes | |
| |
| |
Abstract Methods | |
| |
| |
Picturing Abstract Classes and Methods | |
| |
| |
Using Abstraction in the Car Hierarchy | |
| |
| |
The Car Class as an Abstract Class | |
| |
| |
The Economy Class as an Abstract Class | |
| |
| |
Creating a Concrete Class | |
| |
| |
Other Concrete and Abstract Classes | |
| |
| |
Polymorphic Uses of Abstract Data Types | |
| |
| |
References and Identifiers | |
| |
| |
References and Collections | |
| |
| |
Interfaces | |
| |
| |
Multiple Inheritance and the Use of Interfaces | |
| |
| |
Picturing Interfaces | |
| |
| |
Creating a Test Application | |
| |
| |
Implementing a GUI Application | |
| |
| |
Accommodating Window Closing Events | |
| |
| |
Inner Classes | |
| |
| |
Explicitly Named Inner Classes | |
| |
| |
Inner Anonymous and Final Classes | |
| |
| |
Summary | |
| |
| |
Graphic User Interface Activities | |
| |
| |
Setting Up a Window | |
| |
| |
Lab View A | |
| |
| |
Layout Management | |
| |
| |
Other Layout Managers | |
| |
| |
Pluggable Look and Feel | |
| |
| |
Adding Menu Features | |
| |
| |
Arrays and Patterns | |
| |
| |
Lab View B | |
| |
| |
Event Handling | |
| |
| |
The Handler | |
| |
| |
Associating Events with Menu Items | |
| |
| |
Identifying and Processing Messages | |
| |
| |
JOptionPane Dialogs | |
| |
| |
Window Location Using the Java Toolkit | |
| |
| |
Use of a JLabel Object for a Status Bar | |
| |
| |
Summary | |
| |
| |
Refactoring and Data Containers | |
| |
| |
Custom Dialogs and the Lab View Application | |
| |
| |
Refactoring and Software Patterns | |
| |
| |
Models and Views | |
| |
| |
Refactoring the showElements() Method | |
| |
| |
Implementing the Elements Class | |
| |
| |
Hashtable | |
| |
| |
Hashtable Construction Activities | |
| |
| |
Tokenizing a String | |
| |
| |
Enumeration | |
| |
| |
ArrayList | |
| |
| |
String and StringBuffer | |
| |
| |
Glyph Problems | |
| |
| |
Tabs | |
| |
| |
Cleaning Up Data | |
| |
| |
The Inner Class and the finalize Method | |
| |
| |
Mutator and Accessor Methods of the Elements Class | |
| |
| |
Exceptions | |
| |
| |
Summary | |
| |
| |
Extending Applications | |
| |
| |
Using Dialogs to Extend the Application | |
| |
| |
Child Windows | |
| |
| |
The JDialog Window | |
| |
| |
JDialog Construction | |
| |
| |
Disposal and Initialization | |
| |
| |
The Box Layout Manager | |
| |
| |
Fonts | |
| |
| |
Lab View Menu Considerations | |
| |
| |
An Abstract Primary Dialog | |
| |
| |
Mouse Drawing and Graphics | |
| |
| |
Input/Output Operations | |
| |
| |
Writing to a File | |
| |
| |
Reading from a File | |
| |
| |
Reading Information for a Help Dialog | |
| |
| |
The TableMaker Class | |
| |
| |
Layout for the Dialog | |
| |
| |
Event Processing | |
| |
| |
Processing Details | |
| |
| |
Other Concerns | |
| |
| |
Summary | |
| |
| |
ConTEXT for Java | |
| |
| |
Setting Up an Editor for Java | |
| |
| |
Obtaining ConTEXT | |
| |
| |
Installing ConTEXT | |
| |
| |
Setting ConTEXT Options | |
| |
| |
Accessing Your Java Files | |
| |
| |
Selecting the Highlighter for Java | |
| |
| |
Setting Up the Highlighter | |
| |
| |
Setting Up Associations | |
| |
| |
Setting the Backup Directory | |
| |
| |
Word Wrap and the Ruler | |
| |
| |
Setting the Function Keys | |
| |
| |
Associating F9 with the javac Command | |
| |
| |
Testing F9 | |
| |
| |
Associating F10 with the java Command | |
| |
| |
Testing F10 | |
| |
| |
Index | |