Java For Dummies, 5th Edition
About the Author
Dedication
Author’s Acknowledgments
Table of Contents
Introduction
How to Use This Book
Conventions Used in This Book
What You Don’t Have to Read
Foolish Assumptions
How This Book Is Organized
Icons Used in This Book
Where to Go from Here
Part I: Getting Started
Chapter 1: All about Java
What You Can Do with Java
Why You Should Use Java
Getting Perspective: Where Java Fits In
Object-Oriented Programming (OOP)
What’s Next?
Chapter 2: All about Software
Quick-Start Instructions
What You Install on Your Computer
Chapter 3: Using the Basic Building Blocks
Speaking the Java Language
Checking Out Java Code for the First Time
Understanding a Simple Java Program
And Now, a Few Comments
Part II: Writing Your Own Java Programs
Chapter 4: Making the Most of Variables and Their Values
Varying a Variable
Assignment Statements
Understanding the Types of Values That Variables May Have
Displaying Text
Numbers without Decimal Points
Combining Declarations and Initializing Variables
The Atoms: Java’s Primitive Types
The Molecules and Compounds: Reference Types
An Import Declaration
Creating New Values by Applying Operators
Chapter 5: Controlling Program Flow with Decision-Making Statements
Making Decisions (Java if Statements)
Forming Conditions with Comparisons and Logical Operators
Building a Nest
Choosing among Many Alternatives (Java switch Statements)
Chapter 6: Controlling Program Flow with Loops
Repeating Instructions Over and Over Again (Java while Statements)
Repeating a Certain Number of Times (Java for Statements)
Repeating Until You Get What You Want (Java do Statements)
Part III: Working with the Big Picture: Object-Oriented Programming
Chapter 7: Thinking in Terms of Classes and Objects
Defining a Class (What It Means to Be an Account)
Defining a Method within a Class (Displaying an Account)
Sending Values to and from Methods (Calculating Interest)
Making Numbers Look Good
Hiding Details with Accessor Methods (Why You Shouldn’t Micromanage a Bank Teller)
Chapter 8: Saving Time and Money: Reusing Existing Code
Defining a Class (What It Means to Be an Employee)
Working with Disk Files (A Brief Detour)
Defining Subclasses (What It Means to Be a Full-Time or Part-Time Employee)
Using Subclasses
Overriding Existing Methods (Changing the Payments for Some of Your Employees)
Chapter 9: Constructing New Objects
Defining Constructors (What It Means to Be a Temperature)
More Subclasses (Doing Something about the Weather)
A Constructor That Does More
Part IV: Savvy Java Techniques
Chapter 10: Putting Variables and Methods Where They Belong
Defining a Class (What It Means to Be a Baseball Player)
Making Static (Finding the Team Average)
Experiments with Variables
Passing Parameters
Chapter 11: Using Arrays and Collections to Juggle Values
Getting Your Ducks All in a Row
Arrays of Objects
Command Line Arguments
Using Java Collections
Chapter 12: Looking Good When Things Take Unexpected Turns
Handling Exceptions
Handle an Exception or Pass the Buck
Finishing the Job with a finally Clause
Close Those Files!
Chapter 13: Sharing Names among the Parts of a Java Program
Access Modifiers
Classes, Access, and Multipart Programs
Sneaking Away from the Original Code
Protected Access
Access Modifiers for Java Classes
Chapter 14: Responding to Keystrokes and Mouse Clicks
Go On . . . Click That Button
Responding to Things Other Than Button Clicks
Creating Inner Classes
Chapter 15: Writing Java Applets
Applets 101
Making Things Move
Responding to Events in an Applet
Chapter 16: Using Java Database Connectivity
JDBC and Java DB
Creating Data
Retrieving Data
Part V: The Part of Tens
Chapter 17: Ten Ways to Avoid Mistakes
Putting Capital Letters Where They Belong
Breaking Out of a switch Statement
Comparing Values with a Double Equal Sign
Adding Components to a GUI
Adding Listeners to Handle Events
Defining the Required Constructors
Fixing Non-Static References
Staying within Bounds in an Array
Anticipating Null Pointers
Helping Java Find Its Files
Chapter 18: Ten Websites for Java
This Book’s Website
The Horse’s Mouth
Finding News, Reviews, and Sample Code
Looking for Java Jobs
Everyone’s Favorite Sites
Index