Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
Preface
The Philosophy Behind the Book
Object-Oriented Programming
Appendixes
Using the Code Examples
Conventions Used in This Book
O’Reilly Safari
How to Contact Us
Acknowledgments
1. The Way of the Program
What Is Programming?
What Is Computer Science?
Programming Languages
The Hello World Program
Displaying Strings
Escape Sequences
Formatting Code
Debugging Code
Vocabulary
Exercises
2. Variables and Operators
Declaring Variables
Assignment
State Diagrams
Printing Variables
Arithmetic Operators
Floating-Point Numbers
Rounding Errors
Operators for Strings
Composition
Types of Errors
Vocabulary
Exercises
3. Input and Output
The System Class
The Scanner Class
Program Structure
Inches to Centimeters
Literals and Constants
Formatting Output
Centimeters to Inches
Modulus Operator
Putting It All Together
The Scanner Bug
Vocabulary
Exercises
4. Void Methods
Math Methods
Composition Revisited
Adding New Methods
Flow of Execution
Parameters and Arguments
Multiple Parameters
Stack Diagrams
Reading Documentation
Writing Documentation
Vocabulary
Exercises
5. Conditionals and Logic
Relational Operators
Logical Operators
Conditional Statements
Chaining and Nesting
Flag Variables
The return Statement
Validating Input
Recursive Methods
Recursive Stack Diagrams
Binary Numbers
Vocabulary
Exercises
6. Value Methods
Return Values
Writing Methods
Method Composition
Overloading
Boolean Methods
Javadoc Tags
More Recursion
Leap of Faith
One More Example
Vocabulary
Exercises
7. Loops
The while Statement
Generating Tables
Encapsulation and Generalization
More Generalization
The for Statement
The do-while Loop
break and continue
Vocabulary
Exercises
8. Arrays
Creating Arrays
Accessing Elements
Displaying Arrays
Copying Arrays
Array Length
Array Traversal
Random Numbers
Traverse and Count
Building a Histogram
The Enhanced for Loop
Vocabulary
Exercises
9. Strings and Things
Characters
Strings Are Immutable
String Traversal
Substrings
The indexOf Method
String Comparison
String Formatting
Wrapper Classes
Command-Line Arguments
Vocabulary
Exercises
10. Objects
Point Objects
Attributes
Objects as Parameters
Objects as Return Types
Mutable Objects
Aliasing
The null Keyword
Garbage Collection
Class Diagrams
Java Library Source
Vocabulary
Exercises
11. Classes
The Time Class
Constructors
More Constructors
Getters and Setters
Displaying Objects
The toString Method
The equals Method
Adding Times
Pure Methods and Modifiers
Vocabulary
Exercises
12. Arrays of Objects
Card Objects
Card toString
Class Variables
The compareTo Method
Cards Are Immutable
Arrays of Cards
Sequential Search
Binary Search
Tracing the Code
Recursive Version
Vocabulary
Exercises
13. Objects of Arrays
The Deck Class
Shuffling Decks
Selection Sort
Merge Sort
Subdecks
Merging Decks
Adding Recursion
Vocabulary
Exercises
14. Objects of Objects
Decks and Hands
CardCollection
Inheritance
Dealing Cards
The Player Class
The Eights Class
Class Relationships
Vocabulary
Exercises
A. Development Tools
Installing DrJava
DrJava Interactions
Command-Line Interface
Command-Line Testing
Running Checkstyle
Tracing with a Debugger
Testing with JUnit
Vocabulary
B. Java 2D Graphics
Creating Graphics
Graphics Methods
Example Drawing
Vocabulary
Exercises
C. Debugging
Compile-Time Errors
The compiler is spewing error messages.
I’m getting a weird compiler message, and it won’t go away.
I can’t get my program to compile no matter what I do.
I did what the compiler told me to do, but it still doesn’t work.
Run-Time Errors
My program hangs.
Infinite loop
Infinite recursion
Flow of execution
When I run the program I get an exception.
I added so many print statements I get inundated with output.
Logic Errors
My program doesn’t work.
I’ve got a big hairy expression and it doesn’t do what I expect.
My method doesn’t return what I expect.
My print statement isn’t doing anything.
I’m really, really stuck and I need help.
No, I really need help.
I found the bug!
Index
← Prev
Back
Next →
← Prev
Back
Next →