Preface to: Object-Oriented Programming with Java:
An Introduction

by David J. Barnes
Published by Prentice-Hall

Cover Image: Sense by snailsnail (John Barnes) Copyright 1999

From the Preface


This book is designed for those readers who wish to start learning to program in an object-oriented programming language. It has been designed primarily as a first programming text. It is also suitable for those who already have some experience with another programming language, and who now wish to move on to an object-oriented one. Indeed, much of the material is based on courses delivered by the author to students with a wide range of both non-programming and programming backgrounds. The language we use to teach object-oriented programming is Java.

Since its arrival on the scene in 1995, the adoption of Java as a primary programming language has been amazing. In its favor at the time of its arrival were the facts that it was an object-oriented language, and that it offered a safer and more portable alternative to other languages. It also rode the wave of interest in the World Wide Web, with which it integrated well in its provision of applets. Since then, however, Java has come to be regarded as a genuine mainstream programming language.

Our approach in this book is to regard Java as a language that readers will want to use as a primary tool in many different areas of their programming work - not just for creating programs with graphical content within Web pages. For this reason, in the early chapters we have avoided an emphasis on creating applets and GUI-based programs. While being able to create GUI-based programs is superficially attractive, the language concepts required to create them properly are, in fact, quite advanced. Nevertheless, we recognize that visual examples are much more fun to create and work with. To this end, many of our early examples and exercises are enhanced by the provision of visual material that makes them more interesting to experiment with. An object-oriented language makes this approach relatively easy, without the reader needing to become enmeshed in the details of how they are implemented.

Key Features

The following are key features of this book:

Chapter Outlines

In Chapter 2 through Chapter 15, we cover the most important features of object-oriented programming and the Java language. Within those chapters, exercises have been deliberately positioned between sections, rather than grouped at the end. We recommend that these exercises are attempted at the point they are reached, because many of them are designed to reinforce important concepts that you should feel confident with before moving forward. Each of these chapters also includes periodic reviews to reprise and reinforce the main points of the material covered in the preceding sections. From time to time, case studies are used in order to reinforce or bring out further points that are best made in looking at the design and implementation of a larger problem. In the remaining chapters, we describe in detail how to use many of the GUI components provided by the AWT and Swing classes, how to write multi-threaded programs and how to interact with programs across a network. We conclude with a chapter on simulation - a common application area for object-oriented programs. Throughout the book, there is an emphasis on the importance of good programming style; particularly the need to maintain an object's integrity from outside interference. The individual chapters are organized as follows. The Java API continues to grow, and it is impossible to cover it all in detail within the scope of a teaching text such as this. In Chapter 15, through Chapter 20, therefore, we only attempt to sample the riches of the classes it defines, and provide illustrations of something of what is possible with them. By that stage, our hope is that the reader will be able to harness the power that object-oriented programming in Java permits, and be able to create their own interesting and practical everyday programs.

Supporting Materials

The examples we use have been developed using the Java 2 SDK, which is freely available from the JavaSoft Web site. You are strongly recommended to obtain a copy of the documentation on the Java API which is available from the JavaSoft site. The source code for the examples in this book is available from the publisher's Companion Website or from here either via HTTP or via FTP.

Material for instructors are also available. These include solutions to sample exercises taken from Chapters 1 to 15, and PowerPoint slides for the same set of chapters.

Taken from the book, Object Oriented Programming with Java: An Introduction, by David J. Barnes. Published by Prentice Hall, January 2000.
This document ( is maintained by: David Barnes, to whom any comments and corrections should be addressed.
© 1999-2000 David Barnes and Prentice-Hall.
Last updated: 7th February 2000