If you're new to the wonderful world of Java, you may be looking for a good reference/introductory guide to get you started. In his latest article, Simon reviews Ground-Up Java. Read on to find out whether it's a suitable book for those looking to learn Java.
Book Review: Ground-Up Java by Philip Heller - Part 3: Core Java Packages and Using Java in Practice (Page 4 of 5 )
To describe the core packages in Chapter 12, Heller first explains that there are three kinds of packages:
the special package java.lang, which is so fundamental that you never need to import its classes into your programs;
specialist packages such as java.awt, which are only useful for particular kinds of programs (in this case those with a graphical user interface);
general packages such as java.util, which could be useful in any kind of program.
He describes very few core classes in detail (java.lang.Object, java.lang.Integer and java.lang.Math being the exceptions). Instead, he explains how to navigate your way around Sunís JavaDoc to find more detailed explanations of the classes. I like this approach. Heller acknowledges that there is not enough room in the book to explain all (or even many) of the core packages and classes, so he helps you to help yourself. Navigating the JavaDoc is also standard practice for Java programmers, so itís worth introducing it as a valuable skill. Perhaps Heller should have also mentioned that you can download the source code for the Java core packages. Maybe itís just a little too scary for beginners to go rummaging around the inner workings of Java, but on the other hand itís reassuring to know there arenít any secrets.
Chapter 13 does a good job of explaining File Input and Output, and contains some great animated illustrations of chained streams (see Figure 3).
Figure 3: Chained Data Streams
Chapters 14 and 15 provide a good introduction to programming graphical user interfaces in Java (a huge topic in itself), and chapter 16 focuses on events and event-driven programming. Before introducing event-driven programming, Heller first gives a brief introduction to Threads:
ĎI was eight years old. I was waiting my turn to get my hair cut, and I was reading a Superman comic book. The Man of Steel was entertaining some kids at an orphanage by playing ping-pong against himself. He would serve the ball, then run at super-speed to the other side of the table to return the ball. Then he would run back to the original side, and so on. Each time he changed sides, he ran so fast that nobody could see him, and he ended up exactly where he had been before. This created the illusion of two identical supermen.í
The point is, of course, that computers can create the illusion of doing several things at once by rapidly switching from one task to another.
The discussion of event-driven programming leads you through the development of a graphical user-interface for the game of Nim. It starts with a button-driven input and a simple textual output, but ends with a fully graphical user-interface in which buttons are only enabled when their input is allowed.
Chapter 17 brings together knowledge from the rest of the book to present a longer example that contains a graphical user interface, uses loops, arrays and conditional statements, and makes calls to methods that throw exceptions.