Chapter summary

The book is divided into two parts – Part I introduces Java and covers the fundamentals of object-oriented programming (OOP) and programming-in-the-small. By the end of Chapter 7, you will be able to write complete Java applications consisting of several classes interacting via data and method accesses. Part II builds on this foundation by extending the coverage of objects and introducing GUI, applets, networks, Java’s connection mechanisms to databases and data structures.

Chapter 1 Introduction

All about Java on the web using a multimedia presentation on nature conservation with images and applets. A description of how Java software is developed via the software components of a typical computer (editor, compiler and so on) plus an introduction to the diagrammatic notations used in the book and how to use the Java Development System, which is available free from Sun.

Chapter 2 Simple programs

Introduction to Java via two starter programs; fundamentals of classes and objects; all about printing and assignment. Examples involving output and the use of some Java classes such as Locale.

Chapter 3 Structuring

The objective of this chapter is to reach a point where programs can be written which do more than a human would be prepared to do! The areas covered are: Java primitive types, counting loops, methods and parameters. Either side of these, there are sections on how to design good programs, and an introduction to the class diagram notation which is used extensively hereafter. A case study that uses multiple classes and objects is used to bring all these points together and to illustrate the class notation in action.

Chapter 4 Changing the state

Following naturally on from Chapters 2 and 3, we add facilities to read data, and to make decisions that change the path of a program, either by means of selection statements or by means of exceptions. Exceptions have to be done at this point, because they are intimately bound up with the way input is handled in Java.

Chapter 5 Controlling the flow

The last two control structures are discussed – conditional loops and switching. Conditional looping is one of the areas of programming that can be profitably studied at length, and two sections are devoted to loop design. The chapter ends with an interactive game case study which illustrates most of which has gone be-fore.

Chapter 6 Arrays and tables

To complete Java’s programming-in-the-small capabilities, we consider arrays and their applications. The two array-like classes – String and Hashtable – are also discussed in detail and there is an explanation of sorting.

Chapter 7 Formatting

To complete Java’s programming-in-the-small capabilities, we consider arrays and their applications. The two array-like classes – String and Hashtable – are also discussed in detail and there is an explanation of sorting.

Chapter 8 Objects at work

This chapter centres around a case study of an inventory program, looking at dynamically created objects, linked lists and the rules about objects which Java’s strict classing enforces.

Chapter 9 Abstraction and inheritance

Java’s approach to inheritance is covered with genuine working examples. The chapter discusses interfaces as a really useful alternative to multiple inheritance, and shows how abstract classes are used. Potentially difficult subjects of refer-ences and cloning are covered in detail, with diagrams.

Chapter 10 Graphical user interfaces

We assume that the student has not encountered GUI programming before and therefore needs to be introduced gently to the different components such as buttons, text fields, frames and canvases. Each new feature is introduced with an example.

Chapter 11 Event-driven programming

Event-driven programming is treated seriously as a separate topic, and the chapter winds up with a case study of a supermarket till.

Chapter 12 Applets in action

The transition from applications to applets can now be smoothly achieved. The steps for converting applications are given, as well as guidelines for developing applets from scratch. How to add multimedia excitement of sound and images is covered, and the nature conservation system shown in Chapter 1 can now be dissected and explained.

Chapter 13 Networking

Java’s networking facilities are extensive and novel, so this is one of the longest chapters in the book. It starts by looking at URL (universal resource locator) connections, moves on to threads and synchronization, and ends up with socket programming. There are seven different examples as well as a case study of a chat system.

Chapter 14 Database and remote connections

Chapter 15 Algorithms and data structures

This looks at two searching and two sorting algorithms (including Quicksort) and gives an introduction to performance estimation. Classes for stacks (from Java), queues, linked lists and bit sets (from Java again) are then presented with in-depth examples.