Introduction | p. xviii |
Guided tour | p. xxiv |
The background to Java | p. 1 |
The history of Java | p. 1 |
The main features of Java | p. 2 |
What is a program? | p. 3 |
Programming principles | p. 5 |
Programming pitfalls | p. 5 |
Summary | p. 6 |
Exercises | p. 6 |
Answers to self-test questions | p. 7 |
First programs | p. 8 |
Introduction | p. 8 |
Integrated development environments | p. 9 |
Files and folders | p. 9 |
Using an editor | p. 10 |
Creating a first Java program | p. 11 |
The libraries | p. 13 |
Demystifying the program | p. 14 |
Objects, methods: an introduction | p. 15 |
Classes: an analogy | p. 16 |
Using a text field | p. 17 |
Programming principles | p. 19 |
Programming pitfalls | p. 19 |
Grammar spot | p. 20 |
New language elements | p. 20 |
Summary | p. 20 |
Exercises | p. 21 |
Answers to self-test questions | p. 21 |
Using graphics methods | p. 22 |
Introduction | p. 22 |
Events | p. 22 |
The button-click event | p. 24 |
The graphics coordinate system | p. 25 |
Explanation of the program | p. 25 |
Methods for drawing | p. 27 |
Drawing with colours | p. 28 |
Creating a new program | p. 28 |
The sequence concept | p. 29 |
Adding meaning with comments | p. 31 |
Programming principles | p. 31 |
Programming pitfalls | p. 32 |
Grammar spot | p. 32 |
New language elements | p. 32 |
Summary | p. 32 |
Exercises | p. 32 |
Answers to self-test questions | p. 33 |
Variables and calculations | p. 35 |
Introduction | p. 35 |
The nature of int | p. 36 |
The nature of double | p. 36 |
Declaring variables | p. 37 |
The assignment statement | p. 41 |
Calculations and operators | p. 41 |
The arithmetic operators | p. 42 |
The % operator | p. 45 |
Joining strings with the + operator | p. 46 |
Converting between strings and numbers | p. 47 |
Message dialogs and input dialogs | p. 49 |
Formatting text in dialogs with \n | p. 51 |
Converting between numbers | p. 52 |
Constants: using final | p. 53 |
The role of expressions | p. 54 |
Programming principles | p. 55 |
Programming pitfalls | p. 55 |
Grammar spot | p. 56 |
New language elements | p. 56 |
Summary | p. 57 |
Exercises | p. 57 |
Answers to self-test questions | p. 59 |
Methods and parameters | p. 60 |
Introduction | p. 60 |
Writing your own methods | p. 61 |
A first method | p. 62 |
Calling a method | p. 64 |
Passing parameters | p. 64 |
Formal and actual parameters | p. 66 |
A triangle method | p. 67 |
Local variables | p. 70 |
Name clashes | p. 71 |
Event-handling methods and main | p. 72 |
return and results | p. 73 |
Building on methods: drawHouse | p. 76 |
Building on methods: areaHouse | p. 78 |
this and objects | p. 79 |
Overloading | p. 80 |
Programming principles | p. 81 |
Programming pitfalls | p. 82 |
Grammar spot | p. 82 |
New language elements | p. 83 |
Summary | p. 83 |
Exercises | p. 83 |
Answers to self-test questions | p. 86 |
Using objects | p. 88 |
Introduction | p. 88 |
Instance variables | p. 89 |
Instantiation: using constructors with new | p. 92 |
The Random class | p. 92 |
The main method and new | p. 97 |
The Swing toolkit | p. 98 |
Events | p. 98 |
Creating a JButton | p. 99 |
Guidelines for using objects | p. 101 |
The JLabel class | p. 101 |
The JTextField class | p. 103 |
The JPanel class | p. 104 |
The Timer class | p. 104 |
The JSlider class | p. 106 |
The ImageIcon class | p. 109 |
Programming principles | p. 111 |
Programming pitfalls | p. 111 |
Grammar spot | p. 112 |
New language elements | p. 112 |
Summary | p. 112 |
Exercises | p. 112 |
Answers to self-test questions | p. 114 |
Selection | p. 115 |
Introduction | p. 115 |
The if statement | p. 116 |
if...else | p. 118 |
Comparison operators | p. 121 |
Multiple events | p. 129 |
And, or, not | p. 131 |
Nested ifs | p. 134 |
switch | p. 136 |
Boolean variables | p. 139 |
Comparing strings | p. 143 |
Programming principles | p. 143 |
Programming pitfalls | p. 143 |
Grammar spot | p. 145 |
New language elements | p. 146 |
Summary | p. 146 |
Exercises | p. 147 |
Answers to self-test questions | p. 149 |
Repetition | p. 152 |
Introduction | p. 152 |
while | p. 153 |
for | p. 158 |
And, or, not | p. 159 |
do...while | p. 161 |
Nested loops | p. 163 |
Combining control structures | p. 164 |
Programming principles | p. 165 |
Programming pitfalls | p. 165 |
Grammar spot | p. 166 |
New language elements | p. 166 |
Summary | p. 167 |
Exercises | p. 167 |
Answers to self-test questions | p. 169 |
Writing classes | p. 171 |
Introduction | p. 171 |
Designing a class | p. 172 |
Classes and files | p. 175 |
private variables | p. 177 |
public methods | p. 177 |
The get and set methods | p. 179 |
Constructors | p. 180 |
Multiple constructors | p. 181 |
private methods | p. 182 |
Scope rules | p. 184 |
Operations on objects | p. 185 |
Object destruction | p. 186 |
static methods | p. 186 |
static variables | p. 187 |
Programming principles | p. 188 |
Programming pitfalls | p. 189 |
Grammar spot | p. 190 |
New language elements | p. 190 |
Summary | p. 191 |
Exercises | p. 191 |
Answers to self-test questions | p. 193 |
Inheritance | p. 194 |
Introduction | p. 194 |
Using inheritance | p. 195 |
protected | p. 196 |
Scope rules | p. 197 |
Additional items | p. 197 |
Overriding | p. 198 |
Class diagrams | p. 198 |
Inheritance at work | p. 199 |
super | p. 200 |
Constructors | p. 200 |
final | p. 203 |
Abstract classes | p. 204 |
Programming principles | p. 205 |
Programming pitfalls | p. 206 |
New language elements | p. 207 |
Summary | p. 207 |
Exercises | p. 208 |
Answers to self-test questions | p. 209 |
Calculations | p. 210 |
Introduction | p. 210 |
Library mathematical functions and constants | p. 211 |
Formatting numbers | p. 211 |
Case study - money | p. 214 |
Case study - iteration | p. 217 |
Graphs | p. 218 |
Exceptions | p. 222 |
Programming principles | p. 223 |
Programming pitfalls | p. 223 |
Summary | p. 223 |
Exercises | p. 224 |
Answer to self-test question | p. 227 |
Array lists | p. 228 |
Introduction | p. 228 |
Creating an array list and generics | p. 229 |
Adding items to a list | p. 229 |
The length of a list | p. 230 |
Indices | p. 231 |
Displaying an array list | p. 231 |
The enhanced for statement | p. 232 |
Using index values | p. 233 |
Removing items from an array list | p. 234 |
Inserting items within an array list | p. 235 |
Lookup | p. 235 |
Arithmetic on an array list | p. 236 |
Searching | p. 238 |
Programming principles | p. 239 |
Programming pitfalls | p. 240 |
New language elements | p. 240 |
Summary | p. 240 |
Exercises | p. 241 |
Answers to self-test questions | p. 241 |
Arrays | p. 242 |
Introduction | p. 242 |
Creating an array | p. 244 |
Indices | p. 245 |
The length of an array | p. 247 |
Passing arrays as parameters | p. 247 |
The enhanced for statement | p. 248 |
Using constants | p. 249 |
Initializing an array | p. 250 |
A sample program | p. 251 |
Lookup | p. 253 |
Searching | p. 254 |
Arrays of objects | p. 256 |
Programming principles | p. 257 |
Programming pitfalls | p. 258 |
Grammar spot | p. 259 |
Summary | p. 259 |
Exercises | p. 259 |
Answers to self-test questions | p. 263 |
Arrays - two dimensional | p. 265 |
Introduction | p. 265 |
Declaring an array | p. 266 |
Indices | p. 267 |
The size of an array | p. 268 |
Passing arrays as parameters | p. 269 |
Constants | p. 269 |
Initializing an array | p. 270 |
A sample program | p. 271 |
Programming principles | p. 272 |
Programming pitfalls | p. 273 |
Summary | p. 273 |
Exercises | p. 274 |
Answers to self-test questions | p. 277 |
String manipulation | p. 278 |
Introduction | p. 278 |
Using strings - a recap | p. 279 |
The characters within strings | p. 280 |
A note on the char type | p. 280 |
The String class | p. 281 |
The String class methods | p. 281 |
Comparing strings | p. 283 |
Amending strings | p. 285 |
Examining strings | p. 286 |
String conversions | p. 289 |
String parameters | p. 291 |
An example of string processing | p. 291 |
String case study - Frasier | p. 292 |
Programming principles | p. 296 |
Programming pitfalls | p. 297 |
Grammar spot | p. 297 |
New language elements | p. 297 |
Summary | p. 298 |
Exercises | p. 298 |
Answer to self-test question | p. 300 |
Exceptions | p. 301 |
Introduction | p. 301 |
Exceptions and objects | p. 303 |
When to use exceptions | p. 304 |
The jargon of exceptions | p. 304 |
A try-catch example | p. 304 |
try and scopes | p. 307 |
The search for a catcher | p. 308 |
Throwing - an introduction | p. 309 |
Exception classes | p. 310 |
Compilation and checked exceptions | p. 310 |
Catching - the common cases | p. 312 |
Using the exception class structure | p. 314 |
Programming principles | p. 314 |
Programming pitfalls | p. 315 |
Grammar spot | p. 315 |
New language elements | p. 315 |
Summary | p. 316 |
Exercises | p. 316 |
Answers to self-test questions | p. 317 |
Files and console applications | p. 318 |
Introduction | p. 318 |
File access: stream or random? | p. 319 |
The essentials of streams | p. 319 |
The Java I/O classes | p. 320 |
The BufferedReader and PrintWriter classes | p. 320 |
File output | p. 321 |
File input | p. 324 |
File searching | p. 327 |
The File class | p. 331 |
The JFileChooser class | p. 333 |
Console I/O | p. 336 |
The System class | p. 336 |
Using JOptionPane | p. 338 |
A console example: Finder | p. 338 |
Reading from a remote site | p. 340 |
Command-line arguments | p. 342 |
Programming principles | p. 344 |
Programming pitfalls | p. 344 |
Grammar spot | p. 344 |
New language elements | p. 344 |
Summary | p. 345 |
Exercises | p. 346 |
Answers to self-test questions | p. 347 |
Object-oriented design | p. 348 |
Introduction | p. 348 |
The design problem | p. 349 |
Identifying objects and methods | p. 349 |
Case study in design | p. 354 |
Looking for reuse | p. 360 |
Composition or inheritance? | p. 361 |
Guidelines for class design | p. 365 |
Summary | p. 366 |
Exercises | p. 367 |
Answers to self-test questions | p. 368 |
Program style | p. 369 |
Introduction | p. 369 |
Program layout | p. 370 |
Names | p. 371 |
Classes | p. 371 |
Comments | p. 372 |
Constants | p. 373 |
Methods | p. 374 |
Nested ifs | p. 375 |
Nested loops | p. 378 |
Complex conditions | p. 379 |
Documentation | p. 381 |
Consistency | p. 381 |
Programming pitfalls | p. 382 |
Summary | p. 382 |
Exercises | p. 382 |
Testing | p. 383 |
Introduction | p. 383 |
Program specifications | p. 384 |
Exhaustive testing | p. 385 |
Black box (functional) testing | p. 385 |
White box (structural) testing | p. 388 |
Inspections and walkthroughs | p. 390 |
Stepping through code | p. 391 |
Formal verification | p. 391 |
Incremental development | p. 392 |
Programming principles | p. 392 |
Summary | p. 393 |
Exercises | p. 393 |
Answers to self-test questions | p. 395 |
Debugging | p. 397 |
Introduction | p. 397 |
Debugging without a debugger | p. 399 |
Using a debugger | p. 400 |
Common errors - compilation errors | p. 401 |
Common errors - run-time errors | p. 402 |
Common errors - logic errors | p. 403 |
Common errors - misunderstanding the language | p. 403 |
Summary | p. 405 |
Answer to self-test question | p. 405 |
Threads | p. 406 |
Introduction | p. 406 |
Threads | p. 407 |
Starting a thread | p. 411 |
Thread dying | p. 412 |
join | p. 412 |
The state of a thread | p. 412 |
Scheduling, thread priorities and yield | p. 413 |
Programming principles | p. 414 |
Summary | p. 414 |
Exercises | p. 415 |
Answers to self-test questions | p. 415 |
Interfaces | p. 416 |
Introduction | p. 416 |
Interfaces for design | p. 416 |
Interfaces and interoperability | p. 419 |
Interfaces and the Java library | p. 420 |
Multiple interfaces | p. 421 |
Interfaces versus abstract classes | p. 423 |
Programming principles | p. 423 |
Programming pitfalls | p. 423 |
Grammar spot | p. 424 |
New language elements | p. 424 |
Summary | p. 424 |
Exercises | p. 424 |
Answers to self-test questions | p. 425 |
Programming in the large - packages | p. 426 |
Introduction | p. 426 |
Using classes and the import statement | p. 426 |
Creating packages using the package statement | p. 427 |
Packages, files and folders | p. 428 |
Scope rules | p. 429 |
The Java library packages | p. 429 |
Programming pitfalls | p. 430 |
New language elements | p. 430 |
Summary | p. 430 |
Exercise | p. 430 |
Answers to self-test questions | p. 431 |
Polymorphism | p. 432 |
Introduction | p. 432 |
Polymorphism in action | p. 433 |
Programming principles | p. 437 |
Programming pitfalls | p. 438 |
New language elements | p. 438 |
Summary | p. 439 |
Exercises | p. 439 |
Java in context | p. 441 |
Introduction | p. 441 |
Simple | p. 442 |
Object oriented | p. 442 |
Platform independence (portability) | p. 442 |
Performance | p. 443 |
Security | p. 444 |
Netcentric | p. 446 |
Microsoft versus the world | p. 447 |
The versions of Java | p. 448 |
Java capabilities | p. 448 |
Java libraries | p. 448 |
Internationalization | p. 449 |
Databases - JDBC | p. 449 |
RMI - Remote Method Invocation | p. 450 |
Java beans | p. 451 |
Java servlets and JSP | p. 451 |
JavaScript | p. 452 |
Conclusion | p. 453 |
Summary | p. 453 |
Exercises | p. 453 |
Appendices | |
Java libraries | p. 454 |
The Abstract Window Toolkit | p. 496 |
Applets | p. 500 |
Glossary | p. 504 |
Rules for names | p. 506 |
Keywords | p. 507 |
Scope rules (visibility) | p. 508 |
Bibliography | p. 511 |
Using Java on Microsoft Windows | p. 514 |
Using the CD-ROM | p. 518 |
Index | p. 519 |
Table of Contents provided by Ingram. All Rights Reserved. |
The New copy of this book will include any supplemental materials advertised. Please check the title of the book to determine if it should include any access cards, study guides, lab manuals, CDs, etc.
The Used, Rental and eBook copies of this book are not guaranteed to include any supplemental materials. Typically, only the book itself is included. This is true even if the title states it includes any access cards, study guides, lab manuals, CDs, etc.