| |
| |
| |
Introduction to Computers and Java | |
| |
| |
| |
Computer Basics | |
| |
| |
Hardware and Memory | |
| |
| |
Programs | |
| |
| |
Programming Languages, Compilers, and Interpreters | |
| |
| |
Java Bytecode | |
| |
| |
Class Loader | |
| |
| |
| |
A Sip of Java | |
| |
| |
History of the Java Language | |
| |
| |
Applications and Applets | |
| |
| |
A First Java Application Program | |
| |
| |
Writing, Compiling, and Running a Java Program | |
| |
| |
| |
Programming Basics | |
| |
| |
Object-Oriented Programming | |
| |
| |
Algorithms | |
| |
| |
Testing and Debugging | |
| |
| |
Software Reuse | |
| |
| |
| |
Graphics Supplement | |
| |
| |
A Sample Graphics Applet | |
| |
| |
Size and Position of Figures | |
| |
| |
Drawing Ovals and Circles | |
| |
| |
Drawing Arcs | |
| |
| |
Running an Applet | |
| |
| |
| |
Basic Computation | |
| |
| |
| |
Variables and Expressions | |
| |
| |
Variables | |
| |
| |
Data Types | |
| |
| |
Java Identifiers | |
| |
| |
Assignment Statements | |
| |
| |
Simple Input | |
| |
| |
Simple Screen Output | |
| |
| |
Constants | |
| |
| |
Named Constants | |
| |
| |
Assignment Compatibilities | |
| |
| |
Type Casting | |
| |
| |
Arithmetic Operators | |
| |
| |
Parentheses and Precedence Rules | |
| |
| |
Specialized Assignment Operators | |
| |
| |
Case Study: Vending Machine Change | |
| |
| |
Increment and Decrement Operators | |
| |
| |
More About the Increment and Decrement Operators | |
| |
| |
| |
The Class String | |
| |
| |
String Constants and Variables | |
| |
| |
Concatenation of Strings | |
| |
| |
String Methods | |
| |
| |
String Processing | |
| |
| |
Escape Characters | |
| |
| |
The Unicode Character Set | |
| |
| |
| |
Keyboard and Screen I/O | |
| |
| |
Screen Output | |
| |
| |
Keyboard Input | |
| |
| |
Other Input Delimiters (Optional) | |
| |
| |
Formatted Output with printf (Optional) | |
| |
| |
| |
Documentation and Style | |
| |
| |
Meaningful Variable Names | |
| |
| |
Comments | |
| |
| |
Indentation | |
| |
| |
Using Named Constants | |
| |
| |
| |
Graphics Supplement | |
| |
| |
Style Rules Applied to a Graphics Applet | |
| |
| |
Creating a Java GUI Application with the JFrame Class | |
| |
| |
Introducing the Class JOptionPane | |
| |
| |
Reading Input as Other Numeric Types | |
| |
| |
Programming Example: Change-Making Program | |
| |
| |
with Windowing I/O | |
| |
| |
| |
Flow of Control: Branching | |
| |
| |
| |
The if-else Statement | |
| |
| |
The Basic if-else Statement | |
| |
| |
Boolean Expressions | |
| |
| |
Comparing Strings | |
| |
| |
Nested if-else Statements | |
| |
| |
Multibranch if-else Statements | |
| |
| |
Programming Example: Assigning Letter Grades | |
| |
| |
Case Study: Body Mass Index | |
| |
| |
The Conditional Operator (Optional) | |
| |
| |
The exit Method | |
| |
| |
| |
The Type boolean | |
| |
| |
Boolean Variables | |
| |
| |
Precedence Rules | |
| |
| |
Input and Output of Boolean Values | |
| |
| |
| |
The switch Statement | |
| |
| |
Enumerations | |
| |
| |
| |
Graphics Supplement | |
| |
| |
Specifying a Drawing Color | |
| |
| |
A Dialog Box for a Yes-or-No Question | |
| |
| |
| |
Flow of Control: Loops | |
| |
| |
| |
Java Loop Statements | |
| |
| |
The while Statement | |
| |
| |
The do-while Statement | |
| |
| |
Programming Example: Bug Infestation | |
| |
| |
Programming Example: Nested Loops | |
| |
| |
The for Statement | |
| |
| |
Declaring Variables within a for Statement | |
| |
| |
Using a Comma in a for Statement (Optional) | |
| |
| |
The for-each Statement | |
| |
| |
| |
Programming with Loops | |
| |
| |
The Loop Body | |
| |
| |
Initializing Statements | |
| |
| |
Controlling the Number of Loop Iterations | |
| |
| |
Case Study: Using a Boolean Variable to End a Loop | |
| |
| |
Programming Example: Spending Spree | |
| |
| |
The break Statement and continue Statement in Loops | |
| |
| |
(Optional) | |
| |
| |
Loop Bugs | |
| |
| |
Tracing Variables | |
| |
| |
Assertion Checks | |
| |
| |
| |
Graphics Supplement | |
| |
| |
Programming Example: A Multiface Applet | |
| |
| |
The drawstring Method | |
| |
| |
| |
Defining Classes and Methods | |
| |
| |
| |
Class and Method Definitions | |
| |
| |
Class Files and Separate Compilation | |
| |
| |
Programming Example: Implementing a Dog Class | |
| |
| |
Instance Variables | |
| |
| |
Methods | |
| |
| |
Defining void Methods | |
| |
| |
Defining Methods That Return a Value | |
| |
| |
Programming Example: First Try at Implementing a Species Class | |
| |
| |
The Keyword this | |
| |
| |
Local Variables | |
| |
| |
Blocks | |
| |
| |
Parameters of a Primitive Type | |
| |
| |
| |
Information Hiding and Encapsulation | |
| |
| |
Information Hiding | |
| |
| |
Precondition and Postcondition Comments | |
| |
| |
The public and private Modifiers | |
| |
| |
Programming Example: A Demonstration of Why Instance | |
| |
| |
Variables Should Be Private | |
| |
| |
Programming Example: Another Implementation of a Class of Rectangles | |
| |
| |
Accessor Methods and Mutator Methods | |
| |
| |
Programming Example: A Purchase Class | |
| |
| |
Methods Calling Methods | |
| |
| |
Encapsulation | |
| |
| |
Automatic Documentation with javadoc | |
| |
| |
UML Class Diagrams | |
| |
| |
| |
Objects and References | |
| |
| |
Variables of a Class Type | |
| |
| |
Defining an equals Method for a Class | |
| |
| |
Programming Example: A Species Class | |
| |
| |
Boolean-Valued Methods | |
| |
| |
Case Study: Unit Testing | |
| |
| |
Parameters of a Class Type | |
| |
| |
Programming Example: Class-Type Parameters Versus | |
| |
| |
Primitive-Type Parameters | |
| |
| |
| |
Graphics Supplement | |
| |
| |
The Graphics Class | |
| |
| |
Programming Example: Multiple Faces, but with a Helping | |
| |
| |
Method | |
| |
| |
The init Method | |
| |
| |
Adding Labels to an Applet | |
| |
| |
| |
More About Objects and Methods | |
| |
| |
| |
Constructors | |
| |
| |
Defining Constructors | |
| |
| |
Calling Methods from Constructors | |
| |
| |
Calling a Constructor from Other Constructors (Optional) | |
| |
| |
| |
Static Variables and Static Methods | |
| |
| |
Static Variables | |
| |
| |
Static Methods | |
| |
| |
Dividing the Task of a main Method into Subtasks | |
| |
| |
Adding a main Method to a Class | |
| |
| |
The Math Class | |
| |
| |
Wrapper Classes | |
| |
| |
| |
Writing Methods | |
| |
| |
Case Study: Formatting Output | |
| |
| |
Decomposition | |
| |
| |
Addressing Compiler Concerns | |
| |
| |
Testing Methods | |
| |
| |
| |
Overloading | |
| |
| |
Overloading Basics | |
| |
| |
Overloading and Automatic Type Conversion | |
| |
| |
Overloading and the Return Type | |
| |
| |
Programming Example: A Class for Money | |
| |
| |
| |
Information Hiding Revisited | |
| |
| |
Privacy Leaks | |
| |
| |
| |
Enumeration as a Class | |
| |
| |
| |
Packages | |
| |
| |
Packages and Importing | |
| |
| |
Package Names and Directories | |
| |
| |
Name Clashes | |
| |
| |
| |
Graphics Supplement | |
| |
| |
Adding Buttons | |
| |
| |
Event-Driven Programming | |
| |
| |
Programming Buttons | |
| |
| |
Programming Example: A Complete Applet with Buttons | |
| |
| |
Adding Icons | |
| |
| |
Changing Visibility | |
| |
| |
Programming Example: An Example of Changing Visibility | |
| |
| |
| |
Arrays | |
| |
| |
| |
Array Basics | |
| |
| |
Creating and Accessing Arrays | |
| |
| |
Array Details | |
| |
| |
The Instance Variable length | |
| |
| |
More About Array Indices | |
| |
| |
Initializing Arrays | |
| |
| |
| |
Arrays in Classes and Methods | |
| |
| |
Case Study: Sales Report | |
| |
| |
Indexed Variables as Method Arguments | |
| |
| |
Entire Arrays as Arguments to a Method | |
| |
| |
Arguments for the Method main | |
| |
| |
Array Assignment and Equality | |
| |
| |
Methods That Return Arrays | |
| |
| |
| |
Programming with Arrays and Classes | |
| |
| |
Programming Example: A Specialized List Class | |
| |
| |
Partially Filled Arrays | |
| |
| |
| |
Sorting and Searching Arrays | |
| |
| |
Selection Sort | |
| |
| |
Other Sorting Algorithms | |
| |
| |
Searching an Array | |
| |
| |
| |
Multidimensional Arrays | |
| |
| |
Multidimensional-Array Basics | |
| |
| |
Multidimensional-Array Parameters and Returned Values | |
| |
| |
Java's Representation of Multidimensional Arrays | |
| |
| |
Ragged Arrays (Optional) | |
| |
| |
Programming Example: Employee Time Records | |
| |
| |
| |
Graphics Supplement | |
| |
| |
Text Areas and Text Fields | |
| |
| |
Programming Example: A Question-and-Answer Applet | |
| |
| |
The Classes JTextArea and JTextField | |
| |
| |
Drawing Polygons | |
| |
| |
| |
Inheritance, Polymorphism and Interfaces | |
| |
| |
| |
Inheritance Basics | |
| |
| |
Derived Classes | |
| |
| |
Overriding Method Definitions | |
| |
| |
Overriding Versus Overloading | |
| |
| |
The final Modifier | |
| |
| |
Private Instance Variables and Private Methods of a Base Class | |
| |
| |
UML Inheritance Diagrams | |
| |
| |
| |
Programming with Inheritance | |
| |
| |
Constructors in Derived Classes | |
| |
| |
The this Method-Again | |
| |
| |
Calling an Overridden Method | |
| |
| |
Programming Example: A Derived Class of a Derived Class | |
| |
| |
Another Way to Define the equals Methods in Undergraduate | |
| |
| |
Type Compatibility | |
| |
| |
The Class Object | |
| |
| |
A Better equals Method | |
| |
| |
| |
Polymorphism | |
| |
| |
Dynamic Binding and Inheritance | |
| |
| |
Dynamic Binding with toString | |
| |
| |
| |
INTERFACES AND ABSTRACT CLASSES | |
| |
| |
Class Interfaces | |
| |
| |
Java Interfaces | |
| |
| |
Implementing an Interface | |
| |
| |
An Interface as a Type | |
| |
| |
Extending an Interface | |
| |
| |
Case Study: Character Graphics | |
| |
| |
Case Study: The Comparable Interface | |
| |
| |
Abstract Classes | |
| |
| |
| |
Graphics Supplement | |
| |
| |
The Class JApplet | |
| |
| |
The Class JFrame | |
| |
| |
Window Events and Window Listeners | |