Visit www.dummies.com/cheatsheet/beginningprogrammingwithjava to view this book's cheat sheet.
Table of Contents
About This Book How to Use This Book Conventions Used in This Book What You Don’t Have to Read Foolish Assumptions How This Book Is Organized Part I: Revving Up Part II: Writing Your Own Java Programs Part III: Controlling the Flow Part IV: Using Program Units Part V: The Part of Tens Icons Used in This Book Where to Go from Here
Part I: Revving Up Part II: Writing Your Own Java Programs Part III: Controlling the Flow Part IV: Using Program Units Part V: The Part of Tens
Chapter 1: Getting Started What’s It All About? Telling a computer what to do Pick your poison From Your Mind to the Computer’s Processor Translating your code Running code Code you can use Your Java Programming Toolset What’s already on your hard drive? Eclipse Chapter 2: Setting Up Your Computer If You Don’t Like Reading Instructions . . . Getting This Book’s Sample Programs Setting Up Java If you want to avoid installing Java . . . If you’re juggling versions of Java on your computer . . . Setting Up the Eclipse Integrated Development Environment Downloading Eclipse Installing Eclipse Running Eclipse for the first time What’s Next? Chapter 3: Running Programs Running a Canned Java Program Typing and Running Your Own Code Separating your programs from mine Writing and running your program What’s All That Stuff in Eclipse’s Window? Understanding the big picture Views, editors, and other stuff What’s inside a view or an editor? Returning to the big picture
What’s It All About? Telling a computer what to do Pick your poison From Your Mind to the Computer’s Processor Translating your code Running code Code you can use Your Java Programming Toolset What’s already on your hard drive? Eclipse
Telling a computer what to do Pick your poison
Translating your code Running code Code you can use
What’s already on your hard drive? Eclipse
If You Don’t Like Reading Instructions . . . Getting This Book’s Sample Programs Setting Up Java If you want to avoid installing Java . . . If you’re juggling versions of Java on your computer . . . Setting Up the Eclipse Integrated Development Environment Downloading Eclipse Installing Eclipse Running Eclipse for the first time What’s Next?
If you want to avoid installing Java . . . If you’re juggling versions of Java on your computer . . .
Downloading Eclipse Installing Eclipse Running Eclipse for the first time
Running a Canned Java Program Typing and Running Your Own Code Separating your programs from mine Writing and running your program What’s All That Stuff in Eclipse’s Window? Understanding the big picture Views, editors, and other stuff What’s inside a view or an editor? Returning to the big picture
Separating your programs from mine Writing and running your program
Understanding the big picture Views, editors, and other stuff What’s inside a view or an editor? Returning to the big picture
Chapter 4: Exploring the Parts of a Program Checking Out Java Code for the First Time Behold! A program! What the program’s lines say The Elements in a Java Program Keywords Identifiers that you or I can define Identifiers with agreed-upon meanings Literals Punctuation Comments Understanding a Simple Java Program What is a method? The main method in a program How you finally tell the computer to do something The Java class Chapter 5: Composing a Program Computers Are Stupid A Program to Echo Keyboard Input Typing and running a program How the EchoLine program works Getting numbers, words, and other things Type two lines of code and don’t look back Expecting the Unexpected Diagnosing a problem What problem? I don’t see a problem Chapter 6: Using the Building Blocks: Variables, Values, and Types Using Variables Using a variable Understanding assignment statements To wrap or not to wrap? What Do All Those Zeros and Ones Mean? Types and declarations What’s the point? Reading Decimal Numbers from the Keyboard Though these be methods, yet there is madness in ’t Methods and assignments Variations on a Theme Moving variables from place to place Combining variable declarations Chapter 7: Numbers and Types Using Whole Numbers Reading whole numbers from the keyboard What you read is what you get Creating New Values by Applying Operators Finding a remainder The increment and decrement operators Assignment operators Size Matters Chapter 8: Numbers? Who Needs Numbers? Characters I digress . . . One character only, please Variables and recycling When not to reuse a variable Reading characters The boolean Type Expressions and conditions Comparing numbers; comparing characters The Remaining Primitive Types
Checking Out Java Code for the First Time Behold! A program! What the program’s lines say The Elements in a Java Program Keywords Identifiers that you or I can define Identifiers with agreed-upon meanings Literals Punctuation Comments Understanding a Simple Java Program What is a method? The main method in a program How you finally tell the computer to do something The Java class
Behold! A program! What the program’s lines say
Keywords Identifiers that you or I can define Identifiers with agreed-upon meanings Literals Punctuation Comments
What is a method? The main method in a program How you finally tell the computer to do something The Java class
Computers Are Stupid A Program to Echo Keyboard Input Typing and running a program How the EchoLine program works Getting numbers, words, and other things Type two lines of code and don’t look back Expecting the Unexpected Diagnosing a problem What problem? I don’t see a problem
Typing and running a program How the EchoLine program works Getting numbers, words, and other things Type two lines of code and don’t look back
Diagnosing a problem What problem? I don’t see a problem
Using Variables Using a variable Understanding assignment statements To wrap or not to wrap? What Do All Those Zeros and Ones Mean? Types and declarations What’s the point? Reading Decimal Numbers from the Keyboard Though these be methods, yet there is madness in ’t Methods and assignments Variations on a Theme Moving variables from place to place Combining variable declarations
Using a variable Understanding assignment statements To wrap or not to wrap?
Types and declarations What’s the point?
Though these be methods, yet there is madness in ’t Methods and assignments
Moving variables from place to place Combining variable declarations
Using Whole Numbers Reading whole numbers from the keyboard What you read is what you get Creating New Values by Applying Operators Finding a remainder The increment and decrement operators Assignment operators Size Matters
Reading whole numbers from the keyboard What you read is what you get
Finding a remainder The increment and decrement operators Assignment operators
Characters I digress . . . One character only, please Variables and recycling When not to reuse a variable Reading characters The boolean Type Expressions and conditions Comparing numbers; comparing characters The Remaining Primitive Types
I digress . . . One character only, please Variables and recycling When not to reuse a variable Reading characters
Expressions and conditions Comparing numbers; comparing characters
Chapter 9: Forks in the Road Decisions, Decisions! Making Decisions (Java if Statements) Looking carefully at if statements A complete program Indenting if statements in your code Variations on the Theme . . . Or else what? Packing more stuff into an if statement Some handy import declarations Chapter 10: Which Way Did He Go? Forming Bigger and Better Conditions Combining conditions: An example When to initialize? More and more conditions Using boolean variables Mixing different logical operators together Using parentheses Building a Nest Nested if statements Cascading if statements Enumerating the Possibilities Creating an enum type Using an enum type Chapter 11: How to Flick a Virtual Switch Meet the Switch Statement The cases in a switch statement The default in a switch statement Picky details about the switch statement To break or not to break Using Fall-Through to Your Advantage Using a Conditional Operator Chapter 12: Around and Around It Goes Repeating Instructions Over and Over Again (Java while Statements) Following the action in a loop No early bailout Thinking about Loops (What Statements Go Where) Finding some pieces Assembling the pieces Getting values for variables From infinity to affinity Thinking about Loops (Priming) Working on the problem Fixing the problem Chapter 13: Piles of Files: Dealing with Information Overload Running a Disk-Oriented Program A sample program Creating code that messes with your hard drive Running the sample program Troubleshooting problems with disk files Writing a Disk-Oriented Program Reading from a file Writing to a file Writing, Rewriting, and Re-rewriting Chapter 14: Creating Loops within Loops Paying Your Old Code a Little Visit Reworking some existing code Running your code Creating Useful Code Checking for the end of a file How it feels to be a computer Why the computer accidentally pushes past the end of the file Solving the problem Chapter 15: The Old Runaround Repeating Statements a Certain Number Times (Java for Statements) The anatomy of a for statement Initializing a for loop Using Nested for Loops Repeating Until You Get What You Need (Java do Statements) Getting a trustworthy response Deleting files Using Java’s do statement A closer look at the do statement Repeating with Predetermined Values (Java’s Enhanced for Statement) Creating an enhanced for loop Nesting the enhanced for loops
Decisions, Decisions! Making Decisions (Java if Statements) Looking carefully at if statements A complete program Indenting if statements in your code Variations on the Theme . . . Or else what? Packing more stuff into an if statement Some handy import declarations
Looking carefully at if statements A complete program Indenting if statements in your code
. . . Or else what? Packing more stuff into an if statement Some handy import declarations
Forming Bigger and Better Conditions Combining conditions: An example When to initialize? More and more conditions Using boolean variables Mixing different logical operators together Using parentheses Building a Nest Nested if statements Cascading if statements Enumerating the Possibilities Creating an enum type Using an enum type
Combining conditions: An example When to initialize? More and more conditions Using boolean variables Mixing different logical operators together Using parentheses
Nested if statements Cascading if statements
Creating an enum type Using an enum type
Meet the Switch Statement The cases in a switch statement The default in a switch statement Picky details about the switch statement To break or not to break Using Fall-Through to Your Advantage Using a Conditional Operator
The cases in a switch statement The default in a switch statement Picky details about the switch statement To break or not to break
Repeating Instructions Over and Over Again (Java while Statements) Following the action in a loop No early bailout Thinking about Loops (What Statements Go Where) Finding some pieces Assembling the pieces Getting values for variables From infinity to affinity Thinking about Loops (Priming) Working on the problem Fixing the problem
Following the action in a loop No early bailout
Finding some pieces Assembling the pieces Getting values for variables From infinity to affinity
Working on the problem Fixing the problem
Running a Disk-Oriented Program A sample program Creating code that messes with your hard drive Running the sample program Troubleshooting problems with disk files Writing a Disk-Oriented Program Reading from a file Writing to a file Writing, Rewriting, and Re-rewriting
A sample program Creating code that messes with your hard drive Running the sample program Troubleshooting problems with disk files
Reading from a file Writing to a file
Paying Your Old Code a Little Visit Reworking some existing code Running your code Creating Useful Code Checking for the end of a file How it feels to be a computer Why the computer accidentally pushes past the end of the file Solving the problem
Reworking some existing code Running your code
Checking for the end of a file How it feels to be a computer Why the computer accidentally pushes past the end of the file Solving the problem
Repeating Statements a Certain Number Times (Java for Statements) The anatomy of a for statement Initializing a for loop Using Nested for Loops Repeating Until You Get What You Need (Java do Statements) Getting a trustworthy response Deleting files Using Java’s do statement A closer look at the do statement Repeating with Predetermined Values (Java’s Enhanced for Statement) Creating an enhanced for loop Nesting the enhanced for loops
The anatomy of a for statement Initializing a for loop
Getting a trustworthy response Deleting files Using Java’s do statement A closer look at the do statement
Creating an enhanced for loop Nesting the enhanced for loops
Chapter 16: Using Loops and Arrays Some Loops in Action Deciding on a loop’s limit at runtime Using all kinds of conditions in a for loop Reader, Meet Arrays; Arrays, Meet the Reader Storing values in an array Creating a report Working with Arrays Looping in Style Chapter 17: Programming with Objects and Classes Creating a Class Reference types and Java classes Using a newly defined class Running code that straddles two separate files Why bother? From Classes Come Objects Understanding (or ignoring) the subtleties Making reference to an object’s parts Creating several objects Another Way to Think about Classes Classes, objects, and tables Some questions and answers Chapter 18: Using Methods and Variables from a Java Class The String Class A simple example Putting String variables to good use Reading and writing strings Using an Object’s Methods Comparing strings The truth about classes and methods Calling an object’s methods Combining and using data Static Methods Calling static and non-static methods Turning strings into numbers Turning numbers into strings How the NumberFormat works Understanding the Big Picture Packages and import declarations Shedding light on the static darkness Barry makes good on an age-old promise Chapter 19: Creating New Java Methods Defining a Method within a Class Making a method Examining the method’s header Examining the method’s body Calling the method The flow of control Using punctuation The versatile plus sign Let the Objects Do the Work Passing Values to Methods Handing off a value Working with a method header How the method uses the object’s values Getting a Value from a Method An example How return types and return values work Working with the method header (again) Chapter 20: Oooey GUI Was a Worm The Java Swing Classes Showing an image on the screen Just another class Using Eclipse’s WindowBuilder Installing WindowBuilder Creating a GUI class Running your bare-bones GUI class Show me the code Some details about the code Adding Stuff to Your Frame Taking Action
Some Loops in Action Deciding on a loop’s limit at runtime Using all kinds of conditions in a for loop Reader, Meet Arrays; Arrays, Meet the Reader Storing values in an array Creating a report Working with Arrays Looping in Style
Deciding on a loop’s limit at runtime Using all kinds of conditions in a for loop
Storing values in an array Creating a report
Creating a Class Reference types and Java classes Using a newly defined class Running code that straddles two separate files Why bother? From Classes Come Objects Understanding (or ignoring) the subtleties Making reference to an object’s parts Creating several objects Another Way to Think about Classes Classes, objects, and tables Some questions and answers
Reference types and Java classes Using a newly defined class Running code that straddles two separate files Why bother?
Understanding (or ignoring) the subtleties Making reference to an object’s parts Creating several objects
Classes, objects, and tables Some questions and answers
The String Class A simple example Putting String variables to good use Reading and writing strings Using an Object’s Methods Comparing strings The truth about classes and methods Calling an object’s methods Combining and using data Static Methods Calling static and non-static methods Turning strings into numbers Turning numbers into strings How the NumberFormat works Understanding the Big Picture Packages and import declarations Shedding light on the static darkness Barry makes good on an age-old promise
A simple example Putting String variables to good use Reading and writing strings
Comparing strings The truth about classes and methods Calling an object’s methods Combining and using data
Calling static and non-static methods Turning strings into numbers Turning numbers into strings How the NumberFormat works
Packages and import declarations Shedding light on the static darkness Barry makes good on an age-old promise
Defining a Method within a Class Making a method Examining the method’s header Examining the method’s body Calling the method The flow of control Using punctuation The versatile plus sign Let the Objects Do the Work Passing Values to Methods Handing off a value Working with a method header How the method uses the object’s values Getting a Value from a Method An example How return types and return values work Working with the method header (again)
Making a method Examining the method’s header Examining the method’s body Calling the method The flow of control Using punctuation The versatile plus sign
Handing off a value Working with a method header How the method uses the object’s values
An example How return types and return values work Working with the method header (again)
The Java Swing Classes Showing an image on the screen Just another class Using Eclipse’s WindowBuilder Installing WindowBuilder Creating a GUI class Running your bare-bones GUI class Show me the code Some details about the code Adding Stuff to Your Frame Taking Action
Showing an image on the screen Just another class
Installing WindowBuilder Creating a GUI class Running your bare-bones GUI class Show me the code Some details about the code
Chapter 21: Ten Sets of Web Links The Horse’s Mouth Finding News, Reviews, and Sample Code Improving Your Code with Tutorials Finding Help on Newsgroups Reading Documentation with Commentary Listen! Opinions and Advocacy Looking for Java Jobs Finding Out More about Other Programming Languages Everyone’s Favorite Sites Chapter 22: Ten Useful Classes in the Java API Applet ArrayList File Integer Math NumberFormat Scanner String StringTokenizer System
The Horse’s Mouth Finding News, Reviews, and Sample Code Improving Your Code with Tutorials Finding Help on Newsgroups Reading Documentation with Commentary Listen! Opinions and Advocacy Looking for Java Jobs Finding Out More about Other Programming Languages Everyone’s Favorite Sites
Applet ArrayList File Integer Math NumberFormat Scanner String StringTokenizer System