Preface | p. ix |
Introduction to Java Programming | p. 1 |
Computers and Programming Languages | p. 1 |
Arithmetic Calculation: 2 + 2 | p. 2 |
Ten Basic Features of Java | p. 3 |
Compiling and Running a Java Program | p. 6 |
Calculations | p. 9 |
Subtraction, Multiplication, and Division | p. 9 |
Including Output Labels | p. 10 |
Variables of Type double (Real Numbers) | p. 11 |
Assignment Statements | p. 13 |
Rounding Numbers | p. 16 |
Input from a Command Line Parameter | p. 17 |
Character String (String) Variables | p. 18 |
Integer (int) and Other Numerical Variables | p. 19 |
Exercises | p. 23 |
Applets | p. 24 |
Calculation Example Applet | p. 24 |
Applets and HTML | p. 26 |
Publishing an Applet on the World Wide Web | p. 28 |
Including Images in Applets | p. 29 |
Adding Sound to an Applet | p. 30 |
Which to Use: Application or Applets? | p. 31 |
If | p. 33 |
if/else Statements | p. 33 |
Logical Conditions | p. 36 |
And (andand), Or (\\), Not (!) | p. 36 |
The switch Statement: Choosing Between Several Alternatives | p. 38 |
Boolean Variables: true or false | p. 40 |
Exercises | p. 42 |
Loops | p. 43 |
for Loop: Compound Interest | p. 43 |
for Loop: General Form | p. 46 |
Dates | p. 47 |
Nested Loops | p. 48 |
while Loops | p. 51 |
Exercises | p. 54 |
Arrays | p. 57 |
Arrays and Subscripts | p. 57 |
Arrays of Character Strings; Sorting | p. 61 |
Two-dimensional Arrays | p. 64 |
Vectors | p. 67 |
Exercises | p. 68 |
Strings | p. 70 |
Operations on Strings | p. 70 |
Concatenation (+) and length | p. 71 |
Substrings | p. 72 |
Removing Blanks: trim | p. 73 |
Reversing Strings and Palindrome Testing | p. 74 |
Finding Strings Within Strings: indexOf | p. 76 |
Conversion Between Strings and Numbers | p. 77 |
Unicode Values and Encryption | p. 79 |
Exercises | p. 84 |
Methods | p. 85 |
Methods for Common Tasks: Rounding Numbers | p. 85 |
Method Parameters | p. 87 |
General Form: Method Declaration | p. 89 |
Rounding Numbers: Improved Version | p. 90 |
Inserting Commas and Other Strings | p. 91 |
Making Methods Available in Public Classes | p. 94 |
Methods for Playing Cards: Factorials, Combinations, and Probabilities | p. 97 |
Recursion | p. 101 |
Exercises | p. 105 |
Objects and Classes | p. 106 |
Including Values in a Boat Object | p. 106 |
Including Methods in a Class | p. 110 |
Multiple Objects (Instances) of a Class | p. 111 |
Constructors | p. 114 |
Arrays of Objects | p. 115 |
Inheritance: Creating a Class by Extending Another Class | p. 117 |
Constructors for Subclasses That Call the Superclass Constructor | p. 119 |
Abstract Classes: No Objects Allowed | p. 120 |
Polymorphism | p. 120 |
Static Variables and Methods | p. 124 |
Overriding Methods | p. 126 |
Exercises | p. 135 |
Graphics | p. 136 |
Java Commands for Drawing and Filling Shapes | p. 136 |
Smiling Face Applet | p. 140 |
Converting a Java Applet to a Windows-based Java Application | p. 145 |
Colors | p. 149 |
Mathematical Curves | p. 151 |
JAR Files | p. 161 |
Time Series Line Graph | p. 162 |
Fonts | p. 166 |
Including a Graphing Method in Our Boat Class | p. 168 |
Exercises | p. 171 |
Files | p. 172 |
Input and Output from Text Files | p. 172 |
Generating the HTML File for an Applet | p. 172 |
Writing to a File Named by the User | p. 175 |
Reading from a Text File | p. 176 |
Copying from One File to Another | p. 177 |
Copying Selected Lines of One File to Another File | p. 178 |
Alphabetizing the Lines in a File | p. 181 |
Files of Objects | p. 183 |
File Dialog Window | p. 186 |
Exercises | p. 189 |
Mathematical Operations | p. 190 |
Square Root (sqrt) and Absolute Value (abs) | p. 190 |
Trigonometric Functions (sin, cos, tan) | p. 191 |
Polar Coordinates | p. 194 |
Pie Charts | p. 197 |
Logarithms and Exponential Functions | p. 202 |
Numerical Integration | p. 204 |
Exercises | p. 206 |
Windows Programming: Mouse Clicks and Buttons | p. 210 |
Windows, Events, and the Abstract Windowing Toolkit (AWT) | p. 210 |
Mouse Clicks | p. 212 |
Dynamic Graphs | p. 215 |
Buttons | p. 219 |
Outline Code | p. 220 |
Programming with Buttons to Change Colors | p. 221 |
Exercises | p. 227 |
Windows Programming: Dialog Boxes and Menus | p. 228 |
Message Boxes | p. 228 |
Input Boxes | p. 233 |
Check Boxes, Radio Buttons, and Choice Boxes | p. 235 |
Menus | p. 241 |
Including a Menu in an Applet | p. 250 |
Exercises | p. 254 |
Windows Programming: Keyboard Input, Printing, Scrolling, and the Clipboard | p. 255 |
Text Fields | p. 255 |
Key Events | p. 256 |
A Printing Example: A Curve Graphing Program with an Adjustable Scale | p. 259 |
Scrolling | p. 275 |
Using the Clipboard in a Small Word Processing Program | p. 278 |
Exercises | p. 287 |
Programming Strategy | p. 288 |
Computers and Programming Languages | p. 288 |
Why Program in Java? | p. 289 |
Guidelines for Writing Java Programs | p. 293 |
Fixing Compiler Errors | p. 296 |
Exceptions | p. 300 |
Logic Errors | p. 302 |
Games | p. 304 |
Types of Computer Games | p. 304 |
Scoreboard Timer | p. 305 |
Quick Trivia Quiz Game | p. 308 |
Football Strategy Game | p. 315 |
Bouncing Balls | p. 322 |
Exercises | p. 326 |
Scientific Applications | p. 327 |
Scientific Models | p. 327 |
Navigating Across the Surface of the Earth | p. 328 |
This Is Only the Beginning | p. 335 |
Exercises | p. 336 |
Appendices | |
Summary of Java Keywords and Standard Packages and Classes | p. 340 |
HTML | p. 343 |
About the Disc | p. 345 |
Standard Variable Names Used in This Book | p. 347 |
Code Generator | p. 349 |
Index | p. 358 |
Table of Contents provided by Syndetics. All Rights Reserved. |