Developers: Learn a New Programming Language or App Development with Deitel LiveLessons Videos!
Login  |  Register  |  Media Kit  |  Press  |  Contact Us  |   Twitter Become a Deitel Fan on Facebook  
Custom Search
AddThis Social Bookmark Button

Preface: Small Java How to Program

“Be faithful in small things because it is in them that your strength lies.”
Mother Teresa

Welcome to Java and Small Java How to Program, Sixth Edition! At Deitel & Associates, we write college-level computer science textbooks and professional books. This book, our first Special Edition publication, was a joy to create. Our goal was to design a smaller, lower-priced book for one-semester introductory (CS1) courses based on the major revision of Java How to Program, Sixth Edition. Small Java How to Program, Sixth Edition (or 6/e for short) focuses on the core concepts and features of Java covered in Chapters 1–10 of Java How to Program, 6/e.

To create Java How to Program, 6/e, we put the previous edition of Java How to Program under the microscope:

•     All of the chapters have been significantly updated and upgraded.

•     We changed to an early classes and objects pedagogy. Now students build their first reusable classes starting in Chapter 3.

•     All of the GUI in the early chapters has been moved to optional sections.

•     We added substantial case studies throughout the book that build on existing classes from earlier chapters.

•     We incorporated the new features of Sun Microsystems’ latest release of Java—the Java 2 Platform, Standard Edition version 5.0 (J2SE 5.0).

•     We updated our object-oriented presentation to the latest version of the UML (Unified Modeling Language)—UML  2.0.

•     We completely revised the design of the book. This new design uses color, fonts and various design elements to enhance a student’s learning experience.

All of this has been reviewed meticulously by a team of 28 academic and industry reviewers. To form this Special Edition book, we removed the optional OOD/UML case study that appears in Java How to Program, 6/e. The Tour of the Book included in this Preface gives instructors, students and professionals a sense of the Small Java How to Program, 6/e’s coverage of Java and object-oriented programming.

We believe that this book and its support materials have everything instructors and students need for an informative, interesting, challenging and entertaining Java educational experience. In this Preface, we overview the teaching conventions used in the book, such as syntax coloring the code examples, “code washing” and code highlighting. We discuss the software Prentice Hall has bundled with the book as well as the comprehensive suite of educational materials that help instructors maximize their students’ learning experience, including the Instructor’s Resource CD, PowerPoint  Slide lecture notes, lab manuals, companion Web site, course management systems, SafariX (Prentice Hall’s WebBook publications) and more.

As you read this book, if you have any questions, please send an e-mail to; we will respond promptly. Please visit our Web site,, regularly and be sure to sign up for the free Deitel  Buzz Online e-mail newsletter at We use the Web site and the newsletter to keep our readers and industry clients informed of all the latest news on Deitel publications and services. Please check the Web site occasionally for errata, updates regarding the Java software, downloads and other resources.

Features in Small Java How to Program, 6/e

This new edition contains many new and enhanced features including:

Essential Topics for CS1

Small Java How to Program, 6/e focuses on core Java concepts presented in CS1 courses. It is strictly designed for first courses in computing and is appropriate for Computer Science and Information Systems courses.

Updated for the Java 2 Platform Standard Edition 5.0 (J2SE 5.0)

We updated the entire text to reflect the latest release of J2SE 5.0. We have added discussions on the following topics:

•     obtaining formatted input with class Scanner

•     displaying formatted output with the System.out object’s printf method

•     using enhanced for statements to process array elements

•     declaring methods with variable-length argument lists

•     using enum classes that declare sets of constants

•     importing the static members of one class for use in another

In addition, we carefully audited the manuscript against the Java Language Specification (available at The programs you create as you study this text will work with any J2SE 5.0 compatible Java platform.

[Note: Sun Microsystems recently renamed J2SE from the Java 2 Platform, Standard Edition 1.5.0 to the Java 2 Platform, Standard Edition 5.0. However, Sun decided not to replace all occurrences of 1.5.0 with 5.0 in the online Java documentation (available at and in the software installation directory (which is called jdk1.5.0). Sun’s Web site accepts URLs that replace 1.5.0 with 5.0. For example, you can use the URL to access the online documentation.]

New Interior Design

Working with the design team at Prentice Hall, we redesigned the interior styles for our How to Program Series. In response to reader requests, we now place the key terms and the index’s page reference for each defining occurrence in blue, bold style text for easier reference. We emphasize on-screen components in the bold Helvetica font (for example, Properties), and to emphasize program text in the Lucida font (for example, int x = 5).

Syntax Coloring

This book is presented in full color to show programs and their outputs as they typically appear on a computer screen. We syntax color all the Java code, as most Java integrated-development environments and code editors do. This greatly improves code readability—an especially important goal, given that this book contains 4917 lines of code. Our syntax-coloring conventions are as follows:

   comments appear in green
   keywords appear in dark blue
   errors appear in red
   constants and literal values appear in light blue
      all other code appears in black

Code Highlighting

Extensive code highlighting makes it easier for readers to spot the featured segments of each program. The highlighting also helps students review the material rapidly when preparing for exams or labs.

“Code Washing”

Code washing is our term for applying comments, using meaningful identifiers, applying uniform indentation conventions and using vertical spacing to separate meaningful program units. This process results in programs that are extraordinarily readable and self-documenting. We have done extensive “code washing” of all the source-code programs in the text and in the book’s ancillaries. We have worked hard to make our code exemplary; the code has been scrutinized by distinguished academic and industry reviewers.

Early Classes and Objects Approach

One of the most significant improvements in this new edition: Students are now introduced to the concepts of classes and objects in Chapter 1, and start writing their own customized classes and using objects of these classes in Chapter 3. (Prior editions of this book presented these concepts in Chapter 8.) Moving the discussion of objects and classes to earlier chapters in the book gets students “thinking about objects” from the start and helps students master these concepts more thoroughly. Java is not trivial by any means, but it’s fun to program with, and students can see immediate results. Students can get text-based and graphical programs running quickly by using Java’s extensive class libraries of reusable components. Students are typically more creative and productive in a one- or two-semester Java course than in introductory C and C++ courses.

Carefully Tuned Treatment of Object-Oriented Programming in Chapters 8–10

We performed a high-precision upgrade of Java How to Program, 5/e. The improvements make the material clearer and more accessible to students and professionals, especially those studying object-oriented programming (OOP) for the first time. We have completely rewritten the OOP chapters with an integrated case study on developing an employee payroll hierarchy and we motivate interfaces with a payables hierarchy.

Case Studies

This book is loaded with examples and exercises. Often we build on an existing class introduced earlier in the book to demonstrate programming concepts that enhance an application later in the book. This approach allows students to learn these new concepts in the context of an application that they already know. These case studies include the development of the:

•     Time class in Chapter 8

•     Employee payroll application in Chapter 9 and Chapter 10

•     GradeBook class in Chapters 3, 4, 5 and 7

•     polymorphic drawing program in the optional GUI and Graphics case study in Chapters 310

Integrated GradeBook Case Study

To reinforce the book’s early classes presentation, we have included an integrated case study using classes and objects in Chapters 3–5 and 7. We incrementally build a GradeBook class that represents an instructor’s grade book and performs various calculations based on a set of student grades—finding the average, finding the maximum, and minimum, and printing a bar chart. Our goal here is to familiarize students with the important concepts of objects and classes through a real-world example of a class. We develop this class from the ground up, constructing methods from control statements and carefully developed algorithms, and adding instance variables as needed to enhance the functionality of the class.

GUI and Graphics Case Study (Optional)

The optional GUI and Graphics Case Study in Chapters 310 demonstrates techniques for adding visual elements to applications. It is designed for those who want to begin learning Java’s powerful capabilities for creating graphical user interfaces (GUIs) and graphics. Each section introduces a few basic concepts and provides visual, graphical examples and complete source code. In the first few sections, we show how to create simple graphical applications. In the following sections, we use the object-oriented programming concepts presented through Chapter 10 to create an application that draws a variety of shapes polymorphically.

Unified Modeling Language (UML)—Introducing UML 2.0

The Unified Modeling Language (UML) has become the preferred graphical modeling language for designing object-oriented systems. All of the UML diagrams in the book comply with the new UML 2.0 specification. We use UML class diagrams to visually represent classes and their inheritance relationships, and to demonstrate the flow of control in each of Java’s control statements. The larger Java How to Program, 6/e text includes a substantial OOD/UML case study on developing the software for an automated teller machine.

Teaching Approach

Small Java How to Program, 6/e contains a rich collection of examples, exercises and projects drawn from many fields to provide the student with a chance to solve interesting real-world problems. The book concentrates on the principles of good software engineering and stresses program clarity. We avoid arcane terminology and syntax specifications in favor of teaching by example. Our code examples have been tested on popular Java platforms. We are educators who teach leading-edge topics in industry classrooms worldwide. Dr. Harvey M. Deitel has 20 years of college teaching experience and 15 years of industry teaching experience. Paul Deitel has 12 years of industry teaching experience and is one of the world’s most experienced Java corporate trainers, having taught about 100 Java courses since 1996 to government, industry, military and academic clients of Deitel & Associates, Inc.

Learning Java via the Live-Code Approach

Small Java How to Program, 6/e, is loaded with Live-Code examples—each new concept is presented in the context of a complete, working Java application that is immediately followed by one or more sample executions showing the program’s inputs and outputs. This style exemplifies the way we teach and write about programming. We call this method of teaching and writing the Live-Code Approach. We use programming languages to teach programming languages. Reading the examples in the text is much like typing and running them on a computer. We provide all the source code for the book’s examples both on the accompanying CD and at—making it easy for students to run each example as they study it. The book contains 72 complete Live-Code examples consisting of 4917 lines of code.

World Wide Web Access

All of the source-code examples for Small Java How to Program, 6/e, (and our other publications) are available on the Internet as downloads from the following Web sites:

Registration is quick and easy, and the downloads are free. We suggest students download all the examples, then run each program as they read the corresponding text. Making changes to the examples and immediately seeing the effects of those changes is a great way to enhance the Java learning experience.


Each chapter begins with a statement of objectives. This tells students what to expect and gives students an opportunity, after reading the chapter, to determine if they have met these objectives. This is a confidence builder and a source of positive reinforcement.


The learning objectives are followed by quotations. Some are humorous, some are philosophical and some offer interesting insights. Our students enjoy relating the quotations to the chapter material. Many of the quotations are worth a second look after reading the chapter.


The chapter outline helps the student approach the material in a top-down fashion. This, too, helps students anticipate what is to come, and set a comfortable and effective learning pace.

4917 Lines of Code in 72 Example Programs (with Program Outputs)

We present Java features in the context of complete, working Java programs. These Live-Code programs range in size from just a few lines of code to substantial examples containing hundreds of lines of code. Each program is followed by a window containing the outputs produced when the program is run, so students can confirm that the programs run as expected. Relating outputs to the program statements that produce them is an excellent way to learn and to reinforce concepts. Our programs exercise the diverse features of Java. The code is syntax colored, with Java keywords, comments and other program text each appearing in different colors. This facilitates reading the code—students especially will appreciate the syntax coloring when they read the larger programs.

302 Illustrations/Figures

An abundance of charts, tables, line drawings, programs and program outputs is included. We model the flow of control in control statements with UML activity diagrams. We use UML class diagrams to model the fields, constructors and methods of classes.

219 Programming Tips

We include programming tips to help students focus on important aspects of program development. We highlight these tips in the form of Good Programming Practices, Common Programming Errors, Error-Prevention Tips, Performance Tips, Portability Tips and Software Engineering Observations. These tips and practices represent the best we have gleaned from a combined six decades of programming and teaching experience. One of our students—a mathematics major—told us that she feels this approach is like the highlighting of axioms, theorems and corollaries in mathematics books; it provides a basis on which to build good software.


Good Programming Practice

 1.0Good Programming Practices are tips for writing clear programs. These techniques help students produce programs that are more readable, self-documenting and easier to maintain.


Common Programming Error

 1.0Students learning a language—especially in their first programming course—tend to make certain kinds of errors frequently. Focusing on these Common Programming Errors reduces the likelihood that students will make the same mistakes. It also shortens long lines outside instructors’ offices during office hours!


Error-Prevention Tip

 1.0When we first designed this “tip type,” we thought we would use it strictly to tell people how to test and debug Java programs. In fact, many of the tips describe aspects of Java that reduce the likelihood of “bugs” and thus simplify the testing and debugging processes.


Performance Tip

 1.0In our experience, teaching students to write clear and understandable programs is by far the most important goal for a first programming course. But students want to write the programs that run the fastest, use the least memory, require the smallest number of keystrokes, or dazzle in other nifty ways. Students really care about performance. They want to know what they can do to “turbo charge” their programs. So we highlight opportunities for improving program performance—making programs run faster or minimizing the amount of memory that they occupy.


Portability Tip

 1.0One of Java’s “claims to fame” is “universal” portability, so some programmers assume that if they implement an application in Java, the application will automatically be “perfectly” portable across all Java platforms. Unfortunately, this is not always the case. We include Portability Tips to help students write portable code and to provide insights on how Java achieves its high degree of portability.


Software Engineering Observation

 1.0The object-oriented programming paradigm requires a complete rethinking about the way we build software. Java is an effective language for performing good software engineering. The Software Engineering Observations highlight architectural and design issues that affect the construction of software systems, especially large-scale systems. Much of what the student learns here will be useful in upper-level courses and in industry as the student begins to work with large, complex real-world systems.

Wr ap-Up Section

New in this edition, each chapter ends with a brief “wrap-up” section that recaps what topics were presented and what the student learned in the chapter. We have added this feature to help refresh the student’s memory of the material covered and how it relates to the surrounding chapters.

Summary (476 Summary bullets)

Each chapter ends with additional pedagogical devices. We present a thorough, bullet-list-style summary of the chapter. On average, there are 48 summary bullets per chapter. This helps the students review and reinforce key concepts.

Terminology (748 Terms)

We include an alphabetized list of the important terms defined in each chapter—again, for further reinforcement. There is an average of 75 terms per chapter. Each term also appears in the index, and the defining occurrence of each term is highlighted in the index with a blue, bold page number so the student can locate the definitions of terms quickly.

336 Self-Review Exercises and Answers (Count Includes Separate Parts)

Extensive self-review exercises and answers are included for self-study. This gives the student a chance to build confidence with the material and prepare for the regular exercises. We encourage students to do all the self-review exercises and check their answers.

410 Exercises (Count Includes Separate Parts)

Each chapter concludes with a set of exercises, including simple recall of important terminology and concepts; writing individual Java statements; writing small portions of Java methods and classes; writing complete Java methods, classes and applications; and writing major term projects. The large number of exercises across a wide variety of areas enables instructors to tailor their courses to the unique needs of their classes and to vary course assignments each semester. Instructors can use these exercises to form homework assignments, short quizzes and major examinations. The solutions for most of the exercises are included on the Instructor’s Resource CD (IRCD), which is available only to instructors through their Prentice Hall representatives. [NOTE: Please do not write to us requesting the Instructor’s CD. Distribution of this ancillary is limited strictly to college professors teaching from the book. Instructors may obtain the solutions manual only from their Prentice Hall representatives.] Students and professional readers will have access to approximately half the exercises in the book in the free, Web-based Cyber Classroom which will be available in Spring 2005. For more information about the availability of the Cyber Classroom, please visit or sign up for the free Deitel Buzz Online e-mail newsletter at

Approximately 1900 Index Entries

We have included an extensive index at the back of the book. This helps students find terms or concepts by keyword. The Index is useful to people reading the book for the first time and is especially useful to practicing programmers who use the book as a reference.

“Double Indexing” of Java Live-Code Examples

Small Java How to Program, 6/e has 72 live-code examples and 410 exercises (including parts). We have double indexed each of the live-code examples and most of the more substantial exercises. For every source-code program in the book, we took the figure caption and indexed it both alphabetically and as a subindex item under “Examples.” This makes it easier to find examples using particular features. The more substantial exercises are also indexed both alphabetically and as subindex items under “Exercises.”

Tour of the Book

Java is one of today’s most exciting and rapidly developing computer programming languages. Mastering Java will help programmers develop powerful business and personal computer-applications software. In this section, we take a tour of the many capabilities of Java we explore in Small Java How to Program, 6/e.

Chapter 1—Introduction to Computers, the Internet and the Web—discusses what computers are, how they work and how they are programmed. The chapter gives a brief history of the development of programming languages from machine languages, to assembly languages, to high-level languages. The origin of the Java programming language is discussed. The chapter includes an introduction to a typical Java programming environment. The chapter allows readers to “test drive” a typical Java application to gain exposure to the type of applications they will learn to create throughout the book. The chapter also introduces object technology and the Unified Modeling Language.

Chapter 2—Introduction to Java Applications—provides a lightweight introduction to programming applications in the Java programming language. The chapter introduces nonprogrammers to basic programming concepts and constructs. The programs in this chapter illustrate how to display data on the screen to the user and how to obtain data from the user at the keyboard. This chapter introduces J2SE 5.0’s new Scanner class, which greatly simplifies obtaining user input. The chapter also introduces some of J2SE 5.0’s new formatted output capabilities with method System.out.printf. Chapter 2 ends with detailed treatments of decision making and arithmetic operations.

Chapter 3—Introduction to Classes and Objects—introduces classes, objects, methods and instance variables using five real-world examples. The first four of these examples begin our case study on developing a grade-book class that instructors can use to maintain student test scores. The first example presents a GradeBook class with one method that simply displays a welcome message when it is called. We then show how to create an object of that class and call the method so that it displays the welcome message. The second example modifies the first by allowing the method to receive a course name as an argument and by displaying the name as part of the welcome message. The third example shows how to store the course name in a GradeBook object. For this version of the class, we also show how to set the course name and obtain the course name using methods. The fourth example demonstrates how the data in a GradeBook object can be initialized when the object is created—the initialization is performed by the class’s constructor. The last example in the chapter introduces floating-point numbers in the context of a bank account class that maintains a customer’s balance. The chapter describes how to declare a class and use it to create an object. The chapter then discusses how to declare methods in a class to implement the class’s behaviors, how to declare instance variables in a class to implement the class’s attributes and how to call an object’s method to make that method perform its task. The chapter explains the differences between instance variables of a class and local variables of a method, how to use a constructor to ensure that an object’s data is initialized when the object is created, and the differences between primitive and reference types.

Chapter 4—Control Statements: Part 1—focuses on the program-development process. The chapter discusses how to take a problem statement and develop a working Java program from it, including performing intermediate steps in pseudocode. The chapter introduces some primitive types and simple control statements for decision making (if and if...else) and repetition (while). We examine counter-controlled repetition and sentinel-controlled repetition using the GradeBook class from Chapter 3, and introduce Java’s increment, decrement and assignment operators. The chapter includes two enhanced versions of the GradeBook class, each based on the final version presented in Chapter 3. These versions each include a method that uses control statements to calculate the average of a set of student grades. In the first version, the method uses counter-controlled repetition to input 10 student grades from the user, then determines the average grade. In the second version, the method uses sentinel-controlled repetition to input an arbitrary numbers of grades from the user, then calculates the average of the grades that were entered.The chapter uses simple UML activity diagrams to show the flow of control through each of the control statements.

Chapter 5—Control Statements: Part 2—continues the discussions of Java control statements with examples of the for repetition statement, the do...while repetition statement, the switch selection statement, the break statement and the continue statement. A portion of the chapter is devoted to enhancing class GradeBook. We create a version of class GradeBook that uses a switch statement to count the number of A, B, C, D and F grade equivalents in a set of numeric grades entered by the user. This version uses sentinel-controlled repetition to input the grades. While reading the grades from the user, a method modifies instance variables that keep track of the sum of the grades entered and the number of grades entered, as well as the count of grades in each letter grade category. Other methods of the class then use these instance variables to perform the averaging calculation and display a summary report based on the grades entered. The chapter also discusses logical operators.

Chapter 6—Methods: A Deeper Look—takes a deeper look inside objects and their methods. We discuss class-library methods and examine more closely how students can build their own methods. We present our first example of a method with multiple parameters. A portion of the chapter focuses on developing a game playing application that uses random-number generation to simulate the rolling of dice. This application divides its required work into small, reusable methods. The techniques presented in Chapter 6 are essential to the production of properly organized programs, especially the larger programs that system programmers and application programmers are likely to develop. The topic of method overloading (i.e., allowing multiple methods to have the same name as long as they have different “signatures”) is motivated and explained clearly. We introduce the method call stack to explain how Java is able to keep track of which method is currently executing, how local variables of methods are maintained in memory and how a method knows where to return after it completes execution. Additional chapter topics include static methods, static fields, class Math, enumerations and the scope of declarations.

Chapter 7—Arrays—explains how to process lists and tables of values. Arrays in Java are objects, further evidence of Java’s commitment to almost 100% object orientation. We discuss the structuring of data into arrays of data items of the same type. The chapter presents numerous examples of both one-dimensional arrays and multidimensional arrays. Examples in the chapter investigate common array manipulations, printing bar charts, passing arrays to methods and an introduction to the field of survey data analysis (with simple statistics). The chapter also includes a case study simulating the shuffling and dealing of playing cards in a game-playing application, in addition to the final two sections of the GradeBook case study, in which we use arrays to store student grades for the duration of a program’s execution. We include two versions of the class. Previous versions of the class process a set of grades entered by the user, but do not maintain the individual grade values in instance variables of the class. Thus, repeat calculations require the user to reenter the same grades. In this chapter, we use arrays to enable an object of the GradeBook class to maintain a set of grades in memory, thus eliminating the need to repeatedly input the same set of grades. The first version of the class in this chapter stores the grades in a one-dimensional array and can produce a report containing the average of the grades, the minimum and maximum grades and a bar chart representing the grade distribution. The second version of the class in this chapter (i.e., the final version in the case study) uses a two-dimensional array to store the grades of a number of students on multiple exams in a semester. This version can calculate each student’s semester average, as well as the minimum and maximum grades across all grades received for the semester. The class also produces a bar chart displaying the overall grade distribution for the semester. This chapter also introduces J2SE 5.0’s new enhanced for statement to traverse the elements of an array. Variable-length argument lists (new in J2SE 5.0) are also demonstrated.

Chapter 8—Objects: A Deeper Look—begins our deeper discussion of objects and classes. The chapter represents a wonderful opportunity for teaching data abstraction the “right way”—through a language (Java) expressly devoted to implementing new types. Building on the concepts introduced in Chapters 3–7, the chapter focuses on the essence and terminology of classes and objects. In the context of the Time class case study, the chapter discusses implementing Java classes, accessing class members, enforcing information hiding with access modifiers, separating interface from implementation, using access methods and utility methods and initializing objects with constructors. The chapter discusses declaring and using constants, composition, the this reference, static class members and examples of popular abstract data types such as stacks and queues. The chapter introduces the package statement and discusses how to create reusable packages. The chapter also presents J2SE 5.0’s new static import and enum capabilities.

Chapter 9—Object-Oriented Programming: Inheritance—introduces one of the most fundamental capabilities of object-oriented programming languages, inheritance, which is a form of software reusability in which new classes are developed quickly and easily by absorbing the capabilities of existing classes and adding appropriate new capabilities. In the context an Employee hierarchy, this completely revised chapter presents a five-example sequence demonstrating private data, protected data and software reuse via inheritance. We begin by demonstrating a class with private instance variables and public methods to manipulate that data. Next, we implement a second class with several additional capabilities. To do this, we duplicate much of the first example’s code. In our third example, we begin our discussion of inheritance and software reuse—we use the class from the first example as a superclass and inherit its data and functionality into a new subclass. This example introduces the inheritance mechanism and demonstrates that a subclass cannot access its superclass’s private members directly. This motivates our fourth example, in which we introduce protected data in the superclass and demonstrate that the subclass can indeed access the protected data inherited from the superclass. The last example in the sequence demonstrates proper software engineering by defining the superclass’s data as private and using the superclass’s public methods (that were inherited by the subclass) to manipulate the superclass’s private data in the subclass. The chapter discusses the notions of superclasses and subclasses, direct superclasses, indirect superclasses, use of constructors in superclasses and subclasses, and software engineering with inheritance. The chapter also compares inheritance (is a relationships) with composition (has a relationships).

Chapter 10—Object-Oriented Programming: Polymorphism—deals with another fundamental capability of object-oriented programming, namely polymorphic behavior. The completely revised Chapter 10 builds on the inheritance concepts presented in Chapter 9 and focuses on the relationships among classes in a class hierarchy, and the powerful processing capabilities that these relationships enable. A feature of this chapter is its two polymorphism case studies—a payroll system using an abstract class Employee and a payroll system using an interface Payable. Both case studies expand on the Employee hierarchy introduced in Chapter 9. The first case study processes an array of variables that contain references to Employee objects. All the objects referenced by the array elements have a common abstract superclass Employee containing the set of methods common to every class in the hierarchy. The case study demonstrates that when a method is invoked via a superclass reference, the subclass-specific version of that method is invoked. The case study also shows how a program that processes objects polymorphically can still perform type-specific processing by determining the type of the object currently being processed. This chapter distinguishes between abstract classes and concrete classes, and introduces interfaces—Java’s replacement for the feature of C++ called multiple inheritance—in the context of the second payroll case study.

Appendix A—Operator Precedence Chart—lists each of the Java operators and indicates their relative precedence and associativity.

Appendix B—ASCII Character Set—lists the characters of the ASCII (American Standard Code for Information Interchange) character set and indicates the character code value for each. Java uses the Unicode character set with 16-bit characters for representing all of the characters in the world’s “commercially significant” languages. Unicode includes ASCII as a subset.

Appendix C—Keywords and Reserved Words—lists all keywords and reserved words defined in the Java Programming Language Specification.

Appendix D—Primitive Typeslists all primitive types defined in the Java Programming Language Specification.

Appendix E—Number Systems—discusses the binary (base 2), decimal (base 10), octal (base 8) and hexadecimal (base 16) number systems.

Appendix F—Unicode—discusses the Unicode character set, which enables Java to display information in many languages. The appendix provides a sample Java program that displays “Welcome to Unicode” in several different languages.

Appendix G—Using the Java API Documentation—introduces the Java API documentation, which provides easy to use and up-to-the-minute information on Java’s built-in packages. The appendix discusses what is found in the Java API documentation and how this material is organized. The figures in the appendix demonstrate how to navigate the Java API documentation online, including viewing a package, a class and a method. The appendix also demonstrates how to find a particular package, class or method from the index page.

Appendix H—Creating HTML Documentation with javadocintroduces the javadoc documentation generation tool. Sun Microsystems uses the javadoc tool to produce the Java API documentation that is presented in Appendix G. The example in this appendix takes the reader through the javadoc documentation process. First, we introduce the comment style and tags that javadoc recognizes and uses to create documentation. Next, we discuss the commands and options used to run the utility. Finally, we examine the source files javadoc uses and the HTML files javadoc creates.

Appendix I—Labeled break and continue Statements—introduces two additional Java statements that allow programmers to alter the flow of control in control statements.

Appendix J—Using the Debugger—demonstrates key features of the JDK 5.0’s built-in debugger, which allows a programmer to monitor the execution of applications to locate and remove logic errors. The appendix features a series of step-by-step instructions so students learn how to use the debugger in a hands-on manner.

A Tour of the Optional GUI and Graphics Case Study

In this section, we tour the book’s major optional feature—an eight-section case study, on creating graphics and graphical user interfaces (GUIs) in Java. This tour previews the topics covered in each section of the case study. After completing this case study, students will be able to create their own simple graphical applications.

Section 3.9—Using Dialog Boxes—introduces graphical user interfaces and demonstrates handling input and output with dialog boxes. We use predefined JOptionPane dialogs to display information and read text in an application.

Section 4.14—Creating Simple Drawings—introduces Java’s graphics capabilities. First, we describe Java’s coordinate system, then we cover drawing lines and creating a window that displays drawings.

Section 5.10—Rectangles and Ovals—In addition to drawing lines, Java can also draw rectangles and ovals. In this section, we explain how to call the methods to draw a rectangle or an oval.

Section 6.13—Colors and Filled Shapes—explains how the computer represents colors, how we can use colors in our graphics and how to fill oval or rectangular regions with a solid color.

Section 7.13—Drawing Arcs—describes how Java specifies angles. Then we demonstrate drawing arcs (i.e., sections of an oval) by defining an oval and angular positions along the oval.

Section 8.18—Using Objects with Graphics—describes using objects to represent shapes. We create classes to represent each shape type, store these objects in arrays and retrieve the shapes each time we need to draw them.

Section 9.8—Displaying Text and Images Using Labels—covers creating labels and attaching them to the application window. Applications use labels to display information to the user. Labels in Java can display text, an image or both.

Section 10.8—Drawing with Polymorphism—The individual classes created in Section 8.18 have many similar characteristics. We conclude the case study examining these similarities and redesigning the individual shapes so that they inherit their common functionality from a “base” class and can be processed polymorphically.

Software Included with Small Java How to Program, 6/e

A number of for-sale Java development tools are available, but you do not need them to get started with Java. We wrote Small Java How to Program, 6/e using only the new Java 2 Standard Edition Development Kit (JDK), version 5.0. The current JDK version can be downloaded from Sun’s Java Web site This site also contains the JDK documentation downloads.

The CD that accompanies Small Java How to Program, 6/e, contains several Java editors, including BlueJ Version 1.3.5, JCreator Lite Version 3.10 (Windows Only), jEdit Version 4.1 and jGRASP Version 1.7.0. The CD also contains the NetBeans  Version 3.6 Integrated Development Environment (IDE). If you have questions about using this software, please read the documentation on the CD, or read our Dive Into  Series publications, which are available with the resources for Small Java How to Program, 6/e at The free Dive-Into  Series publications help students and instructors familiarize themselves with various Java development tools. These publications include: Dive Into  NetBeans, Dive Into  Eclipse, Dive Into  JBuilder, Dive Into  jEdit, Dive Into  jCreator, Dive Into  jGRASP and Dive Into  BlueJ.

The CD also contains the book’s examples and an HTML Web page with links to the Deitel & Associates, Inc. Web site and the Prentice Hall Web site. If you have access to the Internet, this Web page can be loaded to your Web browser to give you quick access to all the resources.

Teaching Resources for Small Java How to Program, 6/e

Small Java How to Program, 6/e, has extensive resources for instructors. The Instructor’s Resource CD (IRCD) contains the Solutions Manual with solutions to the vast majority of the end-of-chapter exercises, a Test Item File of multiple-choice questions (approximately two per book section) and PowerPoint slides containing all the code and figures in the text, plus bulleted items that summarize the key points in the text. Instructors can customize the slides.

Prentice Hall’s Companion Web Site ( for Small Java How to Program, 6/e offers resources for students and instructors. For instructors, the Companion Web Site offers a Syllabus Manager, which helps instructors plan courses interactively and create online syllabi.

Chapter-specific resources available for students on Companion Web Site include:

•     Chapter objectives.

•     Highlights (e.g., chapter summary).

•     Outline.

•     Tips (e.g., Common Programming Errors, Error-Prevention Tips, Good Programming Practices, Portability Tips, Performance Tips and Software Engineering Observations).

•     Online Study Guide—contains additional short-answer self-review exercises (e.g., true/false) with answers and provides immediate feedback to the student.

Students can track their results and course performance on quizzes using the Student Profile feature, which records and manages all feedback and results from tests taken on the Companion Web Site. To access the Companion Web Site, visit

Java in the Lab

Java in the Lab, Lab Manual to Accompany Java How to Program, 6/e (ISBN# 0-13-149497-X) complements Java How to Program, 6/e and Small Java How to Program 6/e with hands-on lab assignments designed to reinforce students’ understanding of lecture material. This lab manual is designed for closed laboratories: regularly scheduled classes supervised by an instructor. Closed laboratories provide an excellent learning environment, because students can use concepts presented in class to solve carefully designed lab problems. Instructors are better able to gauge the students’ understanding of the material by monitoring the students’ progress in lab. This lab manual also can be used for open laboratories, homework and for self-study. Small Java How to Program, 6/e, and the lab manual also are available together in a value pack (ISBN# 0-13-154126-9).

Each chapter in the lab manual is divided into Prelab Activities, Lab Exercises and Postlab Activities. Each chapter contains objectives that introduce the lab’s key topics and an assignment checklist that allows students to mark which exercises the instructor has assigned. The lab manual pages are perforated, so students can submit their answers (if required).

Solutions to the lab manual’s Prelab Activities, Lab Exercises and Postlab Activities are available in electronic form. Instructors can obtain these materials from their regular Prentice Hall representatives; the solutions are not available to students.

Prelab Activities

Prelab Activities are intended to be completed by students after studying each chapter of Small Java How to Program, 6/e. Prelab Activities test students’ understanding of the textbook and prepare students for the programming exercises in the lab session. The exercises focus on important terminology and programming concepts and are effective for self-review. Prelab Activities include Matching Exercises, Fill-in-the-Blank Exercises, Short-Answer Questions, Programming-Output Exercises (determine what short code segments do without actually running the program) and Correct-the-Code Exercises (identify and correct all errors in short code segments).

Lab Exercises

The most important section in each chapter is the Lab Exercises. These teach students how to apply the material learned in Small Java How to Program, 6/e, and prepare them for writing Java programs. Each lab contains one or more lab exercises and a debugging problem. The Lab Exercises contain the following:

•     Lab Objectives highlight specific concepts on which the lab exercise focuses.

•     Problem Descriptions provide the details of the exercise and hints to help students implement the program.

•     Sample Outputs illustrate the desired program behavior, which further clarifies the problem descriptions and aids the students with writing programs.

•     Program Templates take complete Java programs and replace key lines of code with comments describing the missing code.

•     Problem-Solving Tips highlight key issues that students need to consider when solving the lab exercises.

•     Follow-Up Questions and Activities ask students to modify solutions to lab exercises, write new programs that are similar to their lab-exercise solutions or explain the implementation choices that were made when solving lab exercises.

•     Debugging Problems consist of blocks of code that contain syntax errors and/or logic errors. These alert students to the types of errors they are likely to encounter while programming.

Postlab Activities

Professors typically assign Postlab Activities to reinforce key concepts or to provide students with more programming experience outside the lab. Postlab Activities test the students’ understanding of the Prelab and Lab Exercise material, and ask students to apply their knowledge to creating programs from scratch. The section provides two types of programming activities: coding exercises and programming challenges. Coding exercises are short and serve as review after the Prelab Activities and Lab Exercises have been completed. The coding exercises ask students to write programs or program segments using key concepts from the textbook. Programming Challenges allow students to apply their knowledge to substantial programming exercises. Hints, sample outputs and pseudocode are provided to aid students with these problems. Students who successfully complete the Programming Challenges for a chapter have mastered the chapter material. Answers to the programming challenges are available at

OneKey, CourseCompass , WebCT  and BlackBoard

OneKey is Prentice Hall’s exclusive new resource that gives instructors and students access to the best online teaching and learning tools through one convenient Web site. OneKey enables instructors to prepare their courses effectively, present their courses more dramatically and assess students easily. An abundance of searchable presentation material together with practice activities and test questions—all organized by chapter or topic—helps to simplify course preparation.

Selected content from the Deitels’ introductory programming language How to Program series, including Small Java How to Program, 6/e, is available to integrate into various popular course management systems, including CourseCompass, Blackboard and WebCT. Course management systems help faculty create, manage and use sophisticated Web-based educational tools and programs. Instructors can save hours of inputting data by using Deitel course-management-systems content. [Note: The e-Book included with OneKey contains the entire text of Small Java How to Program, 6/e.]

Blackboard, CourseCompass and WebCT offer:

•     Features to create and customize an online course, such as areas to post course information (e.g., policies, syllabi, announcements, assignments, grades, performance evaluations and progress tracking), class and student management tools, a gradebook, reporting tools, page tracking, a calendar and assignments.

•     Communication tools to help create and maintain interpersonal relationships between students and instructors, including chat rooms, whiteboards, document sharing, bulletin boards and private e-mail.

•     Flexible testing tools that allow an instructor to create online quizzes and tests from questions directly linked to the text, and that grade and track results effectively. All tests can be inputted into the gradebook for efficient course management. WebCT also allows instructors to administer timed online quizzes.

•     Support materials for instructors are available in print and online formats.

In addition to the types of tools found in Blackboard and WebCT, CourseCompass from Prentice Hall includes:

•     CourseCompass course home page, which makes the course as easy to navigate as a book. An expandable table of contents allows instructors to view course content at a glance and to link to any section.

•     Hosting on Prentice Hall’s centralized servers, which allows course administrators to avoid separate licensing fees or server-space issues. Access to Prentice Hall technical support is available.

•     “How Do I” online-support sections are available for users who need help personalizing course sites, including step-by-step instructions for adding PowerPoint slides, video and more.

•     Instructor Quick Start Guide helps instructors create online courses using a simple, step-by-step process.

To view free online demonstrations and learn more about these Course Management Systems, which support Deitel content, visit the following Web sites:

•     Blackboard: and

•     WebCT: and

•     CourseCompass: and

Java 2 Multimedia Cyber Classroom, 6/e Through OneKey

Java How to Program, 6/e and Small Java How to Program, 6/e will now include a free, Web-based interactive multimedia accompaniment to the book—The Java 2 Multimedia Cyber Classroom, 6/e—available in spring 2005 through OneKey. Our Web-based Cyber Classroom will include audio walkthroughs of the code examples in the text, solutions to half of the exercises in the book and more. For more information about the new Web-based Cyber Classroom and its availability through OneKey, please visit our Web site at www.­ or sign up for the free Deitel  Buzz Online e-mail newsletter at www.­

Students and professional users of our Cyber Classrooms tell us that they like the interactivity and that the Cyber Classroom is a powerful reference tool. Professors tell us that their students enjoy using the Cyber Classroom and consequently spend more time on the courses, mastering more of the material than in textbook-only courses. For a complete list of our current CD-ROM-based Cyber Classrooms, see the Deitel  Series page at the beginning of this book, the product listing and ordering information at the end of this book, or visit, or

Pearson Choices

Today’s students have increasing demands on their time and money, and they need to be resourceful about how, when and where they study. Our publisher, Prentice Hall, is owned by Pearson Education, which has responded to that need by creating PearsonChoices to allow faculty and students to choose from a variety of textbook formats and prices.

Small Java How to Program, 6/e is our alternative print edition to Java How to Program, 6/e. Small Java How to Program, 6/e brings the solid and proven pedagogy of our fully updated Java How to Program, 6/e to a new, smaller text that is purely focused on first-semester Computer Science (CS1) programming courses and priced lower than our 29-chapter Java How to Program, 6/e and other competing texts in the CS1 market.

SafariX WebBooks

SafariX Textbooks Online is a new service for college students looking to save money on required or recommended textbooks for academic courses. This secure WebBooks platform creates a new option in the higher education market; an additional choice for students alongside conventional textbooks and online learning services. By eliminating the costs relating to printing, manufacturing and retail distribution for the physical textbook, Pearson provides students with a WebBooks at 50% of the cost of its conventional print equivalent.

SafariX WebBooks are viewed through a Web browser connected to the Internet. No special plug-ins are required and no applications need to be downloaded. Students simply log in, purchase access and begin studying. With SafariX Textbooks Online students will be able to search the text, make notes online, print out reading assignments that incorporate their professors’ lecture notes and bookmark important passages they want to review later. They can navigate easily to a page number, reading assignment, or chapter. The Table of Contents of each WebBook appears in the left hand column alongside the text.

We are pleased to offer students the Small Java How to Program, 6/e SafariX WebBook available for Fall 2004. Visit for more information. Other Deitel titles available as SafariX WebBooks include Java How to Program, 6/e and Simply C++: An Application-Driven Tutorial Approach. Visit for more information.

Java How to Program, Sixth Edition

Java How to Program, 6/e is our 29-chapter book that can be used in classes of all levels. It features a new early classes and early objects approach. The book is up-to-date with J2SE 5.0 and includes comprehensive coverage of the fundamentals of object-oriented programming in Java. Java How to Program, 6/e features a new optional automated teller machine (ATM) case study that teaches the fundamentals of software engineering and object oriented-design with the UML 2.0 in Chapters 1–8 and 10. Other integrated case studies throughout the text include: GUI and graphics (Chapters 3–12); the Time class (Chapter 8); the Employee class (Chapters 9 and 10) and the GradeBook class in Chapters 3–5 and 7. It also features a new interior design including new colors, fonts, design elements and more. The following is a chapter-level table of contents for the book. [Note: The OOD/UML optional automated teller machine (ATM) case study is not included in Small Java How to Program, 6/e.]

Chapters in Both Small Java How to Program, 6/e and Java How to Program, 6/e

Chapter 1—Introduction to Computers, the Internet and the Web

Chapter 2—Introduction to Java Applications

Chapter 3—Introduction to Classes and Objects

Chapter 4—Control Statements: Part 1

Chapter 5—Control Statements Part 2

Chapter 6—Methods: A Deeper Look

Chapter 7—Arrays

Chapter 8—Classes and Objects: A Deeper Look

Chapter 9—Object-Oriented Programming: Inheritance

Chapter 10—Object-Oriented Programming: Polymorphism

Chapters Available Only in Java How to Program, 6/e

Chapter 11—GUI Components: Part 1

Chapter 12—Graphics and Java2D

Chapter 13—Exception Handling

Chapter 14—Files and Streams

Chapter 15—Recursion

Chapter 16—Searching and Sorting

Chapter 17—Data Structures

Chapter 18—Generics

Chapter 19—Collections

Chapter 20—Introduction to Java Applets

Chapter 21—Multimedia: Applets and Applications

Chapter 22—GUI Components: Part 2

Chapter 23—Multithreading

Chapter 24—Networking

Chapter 25—Manipulating Databases with JDBC

Chapter 26—Servlets

Chapter 27—Java Server Pages (JSP)

Chapter 28—Formatted Output

Chapter 29—Strings, Characters and Regular Expressions

Deitel  Buzz Online E-mail Newsletter

Our free e-mail newsletter, the Deitel  Buzz Online, includes commentary on industry trends and developments, links to free articles and resources from our published books and upcoming publications, product-release schedules, errata, challenges, anecdotes, information on our corporate instructor-led training courses and more. To subscribe, visit


One of the great pleasures of writing a textbook is acknowledging the efforts of many people whose names may not appear on the cover, but whose hard work, cooperation, friendship and understanding were crucial to the production of the book. Many people at Deitel & Associates, Inc. devoted long hours to this project.

•     Barbara Deitel, Chief Financial Officer at Deitel & Associates, Inc. researched the quotes at the beginning of each chapter and applied copy-edits to the book.

•     Abbey Deitel, President of Deitel & Associates, Inc., is an Industrial Management graduate of Carnegie Mellon University. She co-authored the Preface. She also suggested the theme and bug names for the cover of the book.

•     Andrew B. Goldberg is a recent graduate of Amherst College, where he earned a degree in Computer Science. Andrew is a co-author with us on Internet and World Wide Web How to Program, 3/e and contributed to Operating Systems, Third Edition. Andrew’s contributions to Small Java How to Program, 6/e included updating the Chapters 3–10 based on the new early-classes presentation of the book and other content revisions. He also co-authored Appendix J: Using the Debugger­.

•     Christi Kelsey is a Management Information Systems graduate of Purdue University. She contributed to Chapter 1, the Preface and Appendix J, Using the Debugger. She edited the Index and paged the entire manuscript.

•     Su Zhang holds B.Sc and a M.Sc degrees in Computer Science from McGill University. She is co-author with us on Java Web Services for Experienced Programmers and Simply Java Programming. She has also contributed to other Deitel publications, including Advanced Java 2 Platform How to Program, Python How to Program and Operating Systems, Third Edition. Su contributed to the sections on the new features of J2SE 5.0 in Chapters 7 and 8. She also co-authored Appendix F, Unicode ; Appendix G, Using Java API Documentation; and Appendix H, Creating HTML Documentation with javadoc.

•     Jing Hu, a participant in the Deitel & Associates, Inc. Summer Internship Program, is a sophomore at Cornell University studying Computer Science. He contributed to the new GUI and Graphics Case Study and the instructor’s manual for Chapters 3–8. He also contributed to the sections on video, preconditions/postconditions, assertions and invariants.

We are fortunate to have worked on this project with the talented and dedicated team of publishing professionals at Prentice Hall. We especially appreciate the extraordinary efforts of our Computer Science Editor, Kate Hargett and her boss and our mentor in publishing—Marcia Horton, Editorial Director of Prentice Hall’s Engineering and Computer Science Division. Jennifer Cappello managed the review process. Vince O’Brien, Tom Manshreck and John Lovell did a marvelous job managing the production of the book. The talents of Carole Anson, Paul Belfanti and Geoffrey Cassar are evident in the re-design of the book’s interior and the new cover art, and Sarah Parker managed the publication of the book’s extensive ancillary package.

We sincerely appreciate the efforts of our fifth edition post-publication reviewers and our sixth edition reviewers:

Sun Microsystems Reviewers

Doug Kohlert, Sun Microsystems, Inc.

Brandon Taylor, Sun Microsystems, Inc.

Academic Reviewers

Karen Arlien, Bismarck State College

Walt Bunch, Chapman University

Marita Ellixson, Eglin AFB/University of Arkansas

Bill Freitas, The Lawrenceville School

Joe Kasprzyk, Salem State College

Earl LaBatt, Altaworks Corp./ University of New Hampshire

Brian Larson, Modesto Junior College

Roberto Lopez-Herrejon, University of Texas at Austin

Dean Mellas, Cerritos College

David Messier, Eastern University

Gavin Osborne, Saskatchewan Institute of Applied Science & Technology

Donna Reese, Mississippi State University

Craig Slinkman, University of Texas at Arlington

Mahendran Velauthapillai, Georgetown University

Stephen Weiss, University of North Carolina at Chapel Hill

Other Industry Reviewers

Jonathan Gadzik, Independent Consultant

Anne Horton, AT&T Bell Laboratories

James Huddleston, Independent Consultant

Karen Tegtmeyer, Independent Consultant

Java How to Program 5/e Post-Publication Reviewers

Ben Blake, Cleveland State University

Walt Bunch, Chapman University

Michael Develle, Independent Consultant

Marita Ellixson, Eglin Air Force Base/University of Arkansas

Ephrem Eyob, Virginia State University

Bjorn Foss, Florida Metropolitan University

James Huddleston, Independent Consultant

Brian Larson, Modesto Junior College

David Messier, Eastern University

Andy Novobilski, University of Tennessee, Chattanooga

Bill O’Farrell, IBM

Richard Ord, University of California, San Diego

Gavin Osborne, Saskatchewan Institute of Applied Science & Technology

Donna Reese, Mississippi State University

Craig Slinkman, University of Texas at Arlington

Brandon Taylor, Sun Microsystems, Inc.

Karen Tegtmeyer, Independent Consultant

Sreedhar Thota, Western Iowa Tech Community College

Mahendran Velauthapillai, Georgetown University

Loran Walker, Lawrence Technological University

Under a tight time schedule, they scrutinized every aspect of the text and made countless suggestions for improving the accuracy and completeness of the presentation.

Well, there you have it! Java is a powerful programming language that will help you write programs quickly and effectively. Java scales nicely into the realm of enterprise-systems development to help organizations build their critical information systems. As you read the book, we would sincerely appreciate your comments, criticisms, corrections and suggestions for improving the text. Please address all correspondence to:

We will respond promptly, and we will post corrections and clarifications on our Web site:

We hope you enjoy learning with Small Java How to Program, Sixth Edition as much as we enjoyed writing it!

Dr. Harvey M. Deitel
Paul J. Deitel

About the Authors

Dr. Harvey M. Deitel, Chairman and Chief Strategy Officer of Deitel & Associates, Inc., has 43 years experience in the computing field, including extensive industry and academic experience. Dr. Deitel earned B.S. and M.S. degrees from the Massachusetts Institute of Technology and a Ph.D. from Boston University. He worked on the pioneering virtual-memory operating-systems projects at IBM and MIT that developed techniques now widely implemented in systems such as UNIX, Linux and Windows XP. He has 20 years of college teaching experience, including earning tenure and serving as the Chairman of the Computer Science Department at Boston College before founding Deitel & Associates, Inc., with his son, Paul J. Deitel. He and Paul are the co-authors of several dozen books and multimedia packages and they are writing many more. With translations published in Japanese, German, Russian, Spanish, Traditional Chinese, Simplified Chinese, Korean, French, Polish, Italian, Portuguese, Greek, Urdu and Turkish, the Deitels’ texts have earned international recognition. Dr. Deitel has delivered hundreds of professional seminars to major corporations, government organizations and the military.

Paul J. Deitel, CEO and Chief Technical Officer of Deitel & Associates, Inc., is a graduate of the MIT’s Sloan School of Management, where he studied Information Technology. Through Deitel & Associates, Inc., he has delivered Java, C, C++, Internet and World Wide Web courses to industry clients, including IBM, Sun Microsystems, Dell, Lucent Technologies, Fidelity, NASA at the Kennedy Space Center, the National Severe Storm Laboratory, Compaq, White Sands Missile Range, Rogue Wave Software, Boeing, Stratus, Cambridge Technology Partners, Open Environment Corporation, One Wave, Hyperion Software, Adra Systems, Entergy, CableData Systems and many other organizations. He has also lectured on C++ and Java for the Boston Chapter of the Association for Computing Machinery. He and his father, Dr. Harvey M. Deitel, are the world’s best-selling Computer Science textbook authors.

About Deitel & Associates, Inc.

Deitel & Associates, Inc., is an internationally recognized corporate training and content-creation organization specializing in computer programming languages, Internet/World Wide Web software technology and object technology education. The company provides instructor-led courses on Internet and World Wide Web programming, object technology, and major programming languages and platforms, such as Java, Advanced Java, C, C++,  .NET programming languages, XML, Perl, Python and more. The founders of Deitel & Associates, Inc., are Dr. Harvey M. Deitel and Paul J. Deitel. The company’s clients include many of the world’s largest computer companies, government agencies, branches of the military and business organizations. Through its 28-year publishing partnership with Prentice Hall, Deitel & Associates, Inc. publishes leading-edge programming textbooks, professional books, interactive multimedia Cyber Classrooms, Complete Training Courses, Web-based training courses and course management systems e-content for popular CMSs such as WebCT, Blackboard and Pearson’s CourseCompass. Deitel & Associates, Inc., and the authors can be reached via e-mail at:

To learn more about Deitel & Associates, Inc., its publications and its worldwide Dive Into Series  Corporate Training curriculum, see the last few pages of this book or visit:

and subscribe to the free Deitel Buzz Online e-mail newsletter at:

Individuals wishing to purchase Deitel books, Cyber Classrooms, Complete Training Courses and Web-based training courses can do so through:

Bulk orders by corporations and academic institutions should be placed directly with Prentice Hall. See the last few pages of this book for worldwide ordering details.

© 1992-2005. Deitel & Associates, Inc. All Rights Reserved.

Safari Trial Subscriptuon

Small Java How to Program Cover

ISBN: 0131486608
© 2005, pp. 600

Order now at

Download Code
Examples and
Other Premium
Content for
Registered Users

Login or Register to download this book's code examples and other premium content.

Update :: January 17, 2020