In Java How to Program, Fourth Edition the Deitels introduce the fundamentals of object-oriented programming in Java. The 4th edition includes an optional 180-page case study that introduces object-oriented design with the UML. Key 4th edition topics include:

Applications/Applets

Swing GUI/Event Handling

Classes/Objects/Interfaces

Encapsulation/Inner Classes

OOP/Inheritance/Polymorphism

Data Structures/Collections

Files/Streams/Serialization

Networking/Client/Server/Internet/Web

Graphics/Java2D/Images/Animation

JMF/Java Sound/Audio/Video/MIDI

(Optional) OOD/UML/Design Patterns

Exceptions/Multithreading

Java How to Program, Fourth Edition includes extensive pedagogic features:

Hundreds of LIVE-CODE™ programs with screen captures that show exact outputs

Extensive World Wide Web and Internet resources to encourage further research

Java How to Program, Fourth Edition is the centerpiece of a family of resources for teaching and learning Java, including Web sites (http://www.prenhall.com/deitel and http://www.deitel.com) with the book's code examples (also on the enclosed CD) and other information for faculty, students and professionals; an optional interactive CD (Java 2 Multimedia Cyber Classroom) containing hyperlinks, audio walkthroughs of the code examples, solutions to about half the book's exercises and e-mail access to the authors atdeitel@deitel.com

For information on current and forthcoming Deitel/Prentice Hall publications including How to Program Series (e-)books, Multimedia Cyber Classrooms, Complete Training Courses (that include Deitel books and Cyber Classrooms) and Web-Based Training Courses see the last few pages of this book.

Welcome to Java How to Program, Fourth Edition and the exciting world of programming with the Java™ 2 Platform, Standard Edition. This book is by an old guy and a young guy. The old guy (HMD; Massachusetts Institute of Technology 1967) has been programming and/or teaching programming for 40 years. The young guy (PJD; MIT 1991) has been programming and/or teaching programming for 22 years, and is both a Sun Certified Java Programmer and a Sun Certified Java Developer. The old guy programs and teaches from experience; the young guy does so from an inexhaustible reserve of energy. The old guy wants clarity; the young guy wants performance. The old guy seeks elegance and beauty; the young guy wants results. We got together to produce a book we hope you will find informative, challenging and entertaining.

In November 1995, we attended an Internet/World Wide Web conference in Boston to hear about Java. A Sun Microsystems representative spoke on Java in a packed convention ballroom. During that presentation, we saw the future of programming unfold. The first edition of Java How to Program was born at that moment and was published as the world's first Java computer science textbook.

The world of Java is evolving so rapidly that Java How to Program: Fourth Edition is being published less than five years after the first edition. This creates tremendous challenges and opportunities for us as authors, for our publisher—Prentice Hall, for instructors, for students and for professional people.

Before Java appeared, we were convinced that C++ would replace C as the dominant application development language and systems programming language for the next decade. However, the combination of the World Wide Web and Java now increases the prominence of the Internet in information systems strategic planning and implementation. Organizations want to integrate the Internet "seamlessly" into their information systems. Java is more appropriate than C++ for this purpose.

New Features in Java How to Program: Fourth Edition

This edition contains many new features and enhancements including:

Full-Color Presentation. The book is now in full color. In the book's earlier two-color editions, the programs were displayed in black and the screen captures appeared in the second color. Full color enables readers to see sample outputs as they would appear on a color monitor. Also, we now syntax color all the Java code, as many of today's Java development environments do. Our syntax-coloring conventions are as follows: – comments appear in green – keywords appear in dark blue – constants and literal values appear in light blue – class, method and variable names appear in black

"Code Washing." This is our own term for the process we used to convert all the programs in the book to a more open layout with enhanced commenting. We have grouped program code into small, well-documented pieces. This greatly improves code readability—an especially important goal for us given that this new edition contains more than 25,000 lines of code.

Tune-Up. We performed a substantial tune-up of the book's contents based on our own notes from extensive teaching in our professional Java seminars. In addition, a distinguished team of reviewers read the third edition book and provided us with their comments and criticisms. There are literally thousands of fine-tuning improvements over the third edition.

Thinking About Objects. This optional 180-page case study introduces object-oriented design (OOD) with the Unified Modeling Language (the UML). Many chapters in this edition end with a "Thinking About Objects" section in which we present a carefully paced introduction to object orientation. Our goal in these sections is to help you develop an object-oriented way of thinking to be able to design and implement more substantial systems. These sections also introduce you to the Unified Modeling Language (UML). The UML is a graphical language that allows people who build systems (e.g., software architects, systems engineers and programmers) to represent their object-oriented designs using a common notation. The "Thinking About Objects" section in Chapter 1 introduces basic concepts and terminology. Chapters 2-13, 15 and 22 (22 is on the CD) and Appendices G, H and I (also on the CD) include optional "Thinking About Objects" sections that present a substantial object-oriented elevator case study that applies the techniques of object-oriented design (OOD). Appendices G, H and I fully implement the case study design in Java code. This case study will help prepare you for the kinds of substantial projects you are likely to encounter in industry. If you are a student and your instructor does not plan to include this case study in your course, you may want to read the case study on your own. We believe it will be well worth your effort to walk through this large and challenging project. The material presented in the case-study sections reinforces the material covered in the corresponding chapters. You will experience a solid introduction to object-oriented design with the UML. Also, you will sharpen your code-reading skills by touring a carefully written and well-documented 3,465-line Java program that completely solves the problem presented in the case study.

Discovering Design Patterns. These optional sections introduce popular object-oriented design patterns in use today. Most of the examples provided in this book contain fewer than 150 lines of code. Such small examples normally do not require an extensive design process. However, some programs, such as our optional elevator-simulation case study, are more complex—they can require thousands of lines of code. Larger systems, such as automated teller machines or air-traffic control systems, could contain millions, or even hundreds of millions, of lines of code. Effective design is crucial to the proper construction of such complex systems. Over the past decade, the software engineering industry has made significant progress in the field of design patterns—proven architectures for constructing flexible and maintainable object-oriented software. Using design patterns can substantially reduce the complexity of the design process. We present several design patterns in Java, but these design patterns can be implemented in any object-oriented language, such as C++, C# or Visual Basic. We describe several design patterns used by Sun Microsystems in the Java API. We use design patterns in many programs in this book, which we will identify in our "Discovering Design Patterns" sections. These programs provide examples of using design patterns to construct reliable, robust object-oriented software.

Chapter 22 (on the CD), Java Media Framework (JMF) and JavaSound. This chapter introduces to Java's audio and video capabilities, enhancing our Chapter 18 multimedia coverage. With the Java Media Framework, a Java program can play audio and video media, and capture audio and video media from devices such as microphones and video cameras. The JMF enables Java developers to create streaming media applications, in which a Java program sends live or recorded audio or video feeds across the Internet to other computers, then applications on those other computers play the media as it arrives over the network. The JavaSound APIs enable programs to manipulate MIDI (Musical Instrument Digital Interface) sounds and captured media (i.e., media from a device such as a microphone). The chapter concludes with a substantial MIDI-processing application that enables users to record MIDI files or select MIDI files to play. Users can create their own MIDI music by interacting with the application's simulated synthesizer keyboard. The application can synchronize playing the notes in a MIDI file with pressing the keys on the simulated synthesizer keyboard—similar to a player piano. Note: Chapters 18 and 22 both provide substantial sets of exercises. Each chapter also has a special section containing additional interesting and challenging multimedia projects. These are intended only as suggestions for major projects. Solutions are not provided for these additional exercises in either the Instructor's Manual or the Java 2 Multimedia Cyber Classroom.

Enhanced TCP/IP-Based Networking. We include a new capstone example in Chapter 17 that introduces multicasting for sending information to groups of network clients. This Deitel Messenger case study emulates many of today's popular instant-messaging applications that enable computer users to communicate with friends, relatives and co-workers over the Internet. This 1130-line, multithreaded, client/server Java program uses most of the techniques presented to this point in the book.

Appendix J (on the CD), Career Opportunities. This detailed appendix introduces career services on the Internet. We explore online career services from the employer and employee's perspective. We suggest sites on which you can submit applications, search for jobs and review applicants (if you are interested in hiring someone). We also review services that build recruiting pages directly into e-businesses. One of our reviewers told us that he had just gone through a job search largely using the Internet and this chapter would have really expanded his search dramatically.

Appendix K (on the CD), Unicode. This appendix overviews the Unicode Standard. As computer systems evolved worldwide, computer vendors developed numeric representations of character sets and special symbols for the local languages spoken in different countries. In some cases, different representations were developed for the same languages. Such disparate character sets made communication between computer systems difficult. Java supports the Unicode Standard (maintained by a non-profit organization called the Unicode Consortium), which defines a single character set with unique numeric values for characters and special symbols in most spoken languages. This appendix discusses the Unicode Standard, overviews the Unicode Consortium Web site (unicode.org) and shows a Java example that displays "Welcome" in eight different languages!

Java 2 Plug-In Moved to Chapter 3, Introduction to Applets. Students enjoy seeing immediate results as they execute their Java programs. This is difficult if those programs are Java applets that execute in Web browsers. Most of today's Web browsers (with the exception of Netscape Navigator 6) do not support Java 2 applets directly, so students must test their applet programs with the applet-viewer utility. Sun Microsystems provides the Java 2 Plug-in to enable Java 2 applets to execute in a Web browser that does not support Java 2. The discussion of the Java Plug-in walks the student through the steps necessary to execute an applet in today's Web browsers.

Chapter 22 and Appendices E-K on the CD. There are so many topics covered in this new edition that we could not fit them all in the book! On the CD that accompanies this book, you will find the following chapter and appendices: Chapter 22, Java Media Framework (JMF) and Java Sound; Appendix E, Number Systems; Appendix F, Creating HTML Documentation with javadoc; Appendix G, Elevator Events and Listener Interfaces; Appendix H, Elevator Model; Appendix I, Elevator View; Appendix J, Career Opportunities; and Appendix K, Unicode.

Chapters Moved toAdvanced Java™ 2 Platform How to Program. Four chapters from Java How to Program, Third Edition have been moved to our new book Advanced Java 2 Platform How to Program and greatly enhanced. These chapters are: Java Database Connectivity (JDBC), Servlets, Remote Method Invocation and JavaBeans. Advanced Java 2 Platform How to Program covers each of these topics in more depth. We present the Table of Contents of Advanced Java 2 Platform How to Program shortly.

Some Notes to Instructors

A World of Object Orientation When we wrote the first edition of Java How to Program, universities were still emphasizing procedural programming in languages like Pascal and C. The leading-edge courses were using object-oriented C++, but these courses were generally mixing a substantial amount of procedural programming with object-oriented programming—something that C++ lets you do, but Java does not. By the third edition of Java How to Program, many universities were switching from C++ to Java in their introductory curricula, and instructors were emphasizing a pure object-oriented programming approach. In parallel with this activity, the software engineering community was standardizing its approach to modeling object-oriented systems with the UML, and the design-patterns movement was taking shape. Java How to Program has many audiences, so we designed the book to be customizable. In particular, we included more than 200 pages of optional material that introduces object-oriented design, the UML and design patterns, and presents a substantial case study in object-oriented design and programming. This material is carefully distributed throughout the book to enable instructors to emphasize "industrial-strength" object-oriented design in their courses.

Students Like Java Students are highly motivated by the fact that they are learning a leading-edge language (Java) and a leading-edge programming paradigm (object-oriented programming) that will be immediately useful to them while in the university environment and when they head into a world in which the Internet and the World Wide Web have a massive prominence. Students quickly discover that they can do great things with Java, so they are willing to put in the extra effort. Java helps programmers unleash their creativity. We see this in the Java courses Deitel & Associates, Inc. teaches. Once our students enter lab, we can't hold them back. They eagerly experiment and explore portions of the Java class libraries that we haven't as yet covered in class. They produce applications that go well beyond anything we've ever tried in our introductory C and C++ courses. And they tell us about projects they "can't wait" to try after the course.

Focus of the Book Our goal was clear—produce a Java textbook for introductory university-level courses in computer programming for students with little or no programming experience, yet offer the depth and the rigorous treatment of theory and practice demanded by traditional, upper-level courses and that satisfies professionals' needs. To meet these goals, we produced a comprehensive book, because our text patiently teaches the basics of computer programming and of the Java language (i.e., data types, control structures, methods, arrays, recursion and other "traditional" programming topics); presents key programming paradigms, including object-based programming, object-oriented programming, event-driven programming and concurrent programming; and provides an extensive treatment of the Java class libraries.

Evolution ofJava How to ProgramJava How to Program (first edition) was the world's first university computer science textbook on Java. We wrote it fresh on the heels of C How to Program, Second Edition and C++ How to Pr...