SPECIAL OFFERS
Keep up with new releases and promotions. Sign up to hear from us.
Register your product to gain access to bonus material or receive a coupon.
Introduces students to the UML and key notational schemes that they will encounter in the real world.
Helps students better interpret the code.
Includes new and revised discussions on important topics throughout the book.
Better focuses Java How to Program, Fourth Edition for its student audience.
If you cover these chapters in your course, we are offering them as a bundle with Java How to Program, Fourth Edition. The ISBN for this bundle is 0-13-074367-4 and it is priced at $4 net more than the book alone.
Advanced Java™ 2 Platform How to Program (0-13-089560-1) contains up-to-date and significantly enhanced coverage of these topics.
Helps to build a stronger foundation in programming skills and provides less rigorous and demanding introductory chapters than in previous editions so students are not overwhelmed.
Enables students to confirm that programs run as expected. Students can also manipulate the code from the CD-ROM in the back of the book or from the book's Companion Website (www.prenhall.com/deitel) or from the author's website (www.deitel.com).
Provides hundreds of valuable programming tips and facilitates learning.
Students can apply what they've learned in each chapter.
CD-ROM with every text includes Java™ 2 Software Development Kit, Standard Edition, Version 1.3 for Windows and Linux (Intel x86); Forte™ for Java™, Release 2.0, Community Edition IDE for all platforms; Java™ Plug-In 1.3 HTML Converter Version 1.3; Java™ Media Framework API 2.1.1; source code for all the book's examples; and hyperlinks to Java demos and Internet resources.
Provides extra hands-on experience and study aids for a minimal additional cost. Includes many hours of detailed, expert audio walkthroughs of the book's hundreds of live-code examples; post-assessment exams with hundreds of short answer questions (all with answers); hundreds of self-review exercises drawn from the text (half with answers); hundreds of programming exercises from the main text (these exercises don't have answers in the main text, but half of these exercises have answers in The Complete Training Course); hundreds of tips that are marked with icons and show how to write Java code that's portable, reusable, and optimized for performance; and full-text searching and hyperlinking.
Each How to Program text can be ordered as a Complete Training Course package, containing the main text and the corresponding Cyber Classroom—an interactive, multimedia, tutorial version of the book. The Complete Training Courses are a great value, giving students additional hands-on experience and study aids for a minimal additional cost.
Each Complete Training Course is compatible with Windows 95, Windows 98, Windows NT and Windows 2000 and includes the following features:
Practice exams that offer students hundreds of short answer test questions and answers.
Hundreds of self-review questions that are drawn from the text, all with answers.
Hundreds of programming exercises that are drawn from the text, half with answers (the main text does not provide any answers to these exercises).
We offer the Complete Training Courses in either CD-ROM or Web-based format. When professors order the Web-based version of a Complete Training Course, their students receive the corresponding How to Program book packaged with a URL and password that gives then six months of access to the Cyber Classroom software via the Web.
If your customer has already received Java How to Program, Fourth Edition, please sample only the Java Multimedia Cyber Classroom CD-ROM (0-13-064935-X) to show them the advantages they would get with The Complete Training Course. Please do not sample The Complete Training Course as they will receive a duplicate copy of the main text.
The authoritative DEITEL LIVE-CODE introduction to programming with the Java 2 Platform, Standard Edition (J2SE)
Java has revolutionized software development with multimedia-intensive, platform-independent, object-oriented code for conventional, Internet-, Intranet- and Extranet-based applications and applets. This exciting new Fourth Edition of the world's best-selling Java textbook now has a companion volumeAdvanced Java 2 Platform How to Programwhich focuses on the Java 2 Platform, Enterprise Edition (J2EE), presents advanced J2SE features and introduces the Java 2 Platform, Micro Edition (J2ME).
Dr. Harvey M. Deitel and Paul J. Deitel are the founders of Deitel & Associates, Inc., the internationally recognized corporate training and content-creation organization specializing in Java, C++, C, Visual C#, Visual Basic®, Visual C++®, .NET, XML, Python, Perl, Internet, Web and object technologies. The Deitels are also the authors of the world's #1 C++ textbookC++ How to Program, 3/eand many other best sellers.
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:
Java How to Program, Fourth Edition includes extensive pedagogic features:
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 at
deitel@deitel.com
For information on worldwide corporate on-site seminars and Web-based training offered by Deitel & Associates, Inc., visit:
http://www.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.
Preface.
1. Introduction to Computers, the Internet and the Web.
Introduction. What Is a Computer? Computer Organization. Evolution of Operating Systems. Personal, Distributed and Client/Server Computing. Machine Languages, Assembly Languages and High-Level Languages. History of C++. History of Java. Java Class Libraries. Other High-Level Languages. Structured Programming. The Internet and the World Wide Web. Basics of a Typical Java Environment. General Notes about Java and This Book. Thinking About Objects: Introduction to Object Technology and the Unified Modeling Language. Discovering Design Patterns: Introduction. Tour of the Book. (Optional) A Tour of the Case Study on Object-Oriented Design with the UML. (Optional) A Tour of the "Discovering Design Patterns" Sections.
Introduction. A First Program in Java: Printing a Line of Text. Modifying Our First Java Program. Displaying Text in a Dialog Box. Another Java Application: Adding Integers. Memory Concepts. Arithmetic. Decision Making: Equality and Relational Operators. (Optional Case Study) Thinking About Objects: Examining the Problem Statement.
Introduction. Sample Applets from the Java 2 Software Development Kit. A Simple Java Applet: Drawing a String. Two More Simple Applets: Drawing Strings and Lines. Another Java Applet: Adding Floating-Point Numbers. Viewing Applets in a Web Browser. Java Applet Internet and World Wide Web Resources. (Optional Case Study) Thinking About Objects: Identifying the Classes in a Problem Statement.
Introduction. Algorithms. Pseudocode. Control Structures. The if Selection Structure. The if/else Selection Structure. The while Repetition Structure. Formulating Algorithms: Case Study 1 (Counter-Controlled Repetition). Formulating Algorithms with Top-Down, Stepwise Refinement: Case Study 2 (Sentinel-Controlled Repetition). Formulating Algorithms with Top-Down, Stepwise Refinement: Case Study 3 (Nested Control Structures). Assignment Operators. Increment and Decrement Operators. Primitive Data Types. (Optional Case Study) Thinking About Objects: Identifying Class Attributes.
Introduction. Essentials of Counter-Controlled Repetition. The for Repetition Structure. Examples Using the for Structure. The switch Multiple-Selection Structure. The do/while Repetition Structure. Statements break and continue. Labeled break and continue Statements. Logical Operators. Structured Programming Summary. (Optional Case Study) Thinking About Objects: Identifying Objects' States and Activities.
Introduction. Program Modules in Java. Math Class Methods. Methods. Method Definitions. Argument Promotion. Java API Packages. Random-Number Generation. Example: A Game of Chance. Duration of Identifiers. Scope Rules. Recursion. Example Using Recursion: The Fibonacci Series. Recursion vs. Iteration. Method Overloading. Methods of Class Japplet. (Optional Case Study) Thinking About Objects: Identifying Class Operations.
Introduction. Arrays. Declaring and Allocating Arrays. Examples Using Arrays. References and Reference Parameters. Passing Arrays to Methods. Sorting Arrays. Searching Arrays: Linear Search and Binary Search. Multiple-Subscripted Arrays. (Optional Case Study) Thinking About Objects: Collaboration Among Objects.
Introduction. Implementing a Time Abstract Data Type with a Class. Class Scope. Controlling Access to Members. Creating Packages. Initializing Class Objects: Constructors. Using Overloaded Constructors. Using Set and Get Methods. Software Reusability. Final Instance Variables. Composition: Objects as Instance Variables of Other Classes. Package Access. Using the this Reference. Finalizers. Static Class Members. Data Abstraction and Encapsulation. (Optional Case Study) Thinking About Objects: Starting to Program the Classes for the Elevator Simulation.
Introduction. Superclasses and Subclasses. protected Members. Relationship between Superclass Objects and Subclass Objects. Constructors and Finalizers in Subclasses. Implicit Subclass-Object-to-Superclass-Object Conversion. Software Engineering with Inheritance. Composition vs. Inheritance. Case Study: Point, Circle, Cylinder. Introduction to Polymorphism. Type Fields and switch Statements. Dynamic Method Binding. final Methods and Classes. Abstract Superclasses and Concrete Classes. Polymorphism Examples. Case Study: A Payroll System Using Polymorphism. New Classes and Dynamic Binding. Case Study: Inheriting Interface and Implementation. Case Study: Creating and Using Interfaces. Inner Class Definitions. Notes on Inner Class Definitions. Type-Wrapper Classes for Primitive Types. (Optional Case Study) Thinking About Objects: Incorporating Inheritance into the Elevator Simulation. (Optional) Discovering Design Patterns: Introducing Creational, Structural and Behavioral Design Patterns.
Introduction. Fundamentals of Characters and Strings. string Constructors. String Methods length, charAt and getChars. Comparing Strings. String Method hashCode. Locating Characters and Substrings in Strings. Extracting Substrings from Strings. Concatenating Strings. Miscellaneous String Methods. Using String Method valueOf. String Method intern. String8uffer Class. StringBuffer Constructors. StringBuffer Methods length, capacity, setLength and ensureCapacity. StringBuffer Methods charAt, setCharAt, getChars and reverse. StringBuffer append Methods. StringBuffer Insertion and Deletion Methods. Character Class Examples. Class StringTokenizer. Card Shuffling and Dealing Simulation. (Optional Case Study) Thinking About Objects: Event Handling.
Introduction. Graphics Contexts and Graphics Objects. Color Control. Font Control. Drawing Lines, Rectangles and Ovals. Drawing Arcs. Drawing Polygons and Polylines. The Java2D API. Java2D Shapes. (Optional Case Study) Thinking About Objects: Designing Interfaces with the UML.
Introduction. Swing Overview. JLabel. Event-Handling Model. JTextField and JPassraordField. JButton. JCheckBox and JRadioButton. JComboBOx. JList. Multiple-Selection Lists. Mouse Event Handling. Adapter Classes. Keyboard Event Handling. Layout Managers. Panels. (Optional Case Study) Thinking About Objects: Use Cases.
Introduction. JTextArea. Creating a Customized Subclass of JPanel. Creating a Self-Contained Subclass of JPanel. JSlider. Windows. Designing Programs that Execute as Applets or Applications. Using Menus with Frames. Using JPopupMenus. Pluggable Look-and-Feel. Using JDesktopPane and JInternalFrame. Layout Managers. BoxLayout Layout Manager. CardLayout Layout Manager. GridBagLayout Layout Manager. GridBagConstraints Constants RELATIVE and REMAINDER. (Optional Case Study) Thinking About Objects: Model-View-Controller. (Optional) Discovering Design Patterns: Design Patterns Used in Packages java.awt and javax.swing.
Introduction. When Exception Handling Should Be Used. Other Error-Handling Techniques. Basics of Java Exception Handling. try Blocks. Throwing an Exception. Catching an Exception. Exception-Handling Example: Divide by Zero. Rethrowing an Exception. throws Clause. Constructors, Finalizers and Exception Handling. Exceptions and Inheritance. finally Block. Using printStackTrace and getMessage.
Introduction. Class Thread: An Overview of the Thread Methods. Thread States: Life Cycle of a Thread. Thread Priorities and Thread Scheduling. Thread Synchronization. Producer/Consumer Relationship without Thread Synchronization. Producer/Consumer Relationship with Thread Synchronization. Producer/Consumer Relationship: The Circular Buffer. Daemon Threads. Rufmable Interface. Thread Groups. (Optional Case Study) Thinking About Objects: Multithreading. (Optional) Discovering Design Patterns: Concurrent Design Patterns.
Introduction. Data Hierarchy. Files and Streams. Creating a Sequential-Access File. Reading Data from a Sequential-Access File. Updating Sequential-Access Files. Random-Access Files. Creating a Random-Access File. Writing Data Randomly to a Random-Access File. Reading Data Sequentially from a Random-Access File. Example: A Transaction-Processing Program. Class File.
Introduction. Manipulating URIs. Reading a File on a Web Server. Establishing a Simple Server Using Stream Sockets. Establishing a Simple Client Using Stream Sockets. Client/Server Interaction with Stream Socket Connections. Connectionless Client/Server Interaction with Datagrams. Client/Server Tic-Tac-Toe Using a Multithreaded Server. Security and the Network. DeitelMessenger Chat Server and Client. (Optional) Discovering Design Patterns: Design Patterns Used in Packages java.io and java.net.
Introduction. Loading, Displaying and Scaling Images. Animating a Series of Images. Customizing LogoAnimator via Applet Parameters. Image Maps. Loading and Playing Audio Clips. Internet and World Wide Web Resources.
Introduction. Self-Referential Classes. Dynamic Memory Allocation. Linked Lists. Stacks. Queues. Trees.
Introduction. vector Class and Enumeration Interface. Stack Class. Dictionary Class. Hashtable Class. properties Class. Random Class. Bit Manipulation and the Bitwise Operators. BitSet Class.
Introduction. Collections Overview. Class Arrays. Interface Collection and Class Collections. Lists. Algorithms. Sets. Maps. Synchronization Wrappers. Unmodifiable Wrappers. Abstract Implementations. (Optional) Discovering Design Patterns: Design Patterns Used in Package java.util.
Introduction. Playing Media. Formatting and Saving Captured Media. RTP Streaming. Java Sound. Playing Sampled Audio. Musical Instrument Digital Interface (MIDI). Internet and World Wide Web Resources. (Optional Case Study) Thinking About Objects: Animation and Sound in the View.
Introduction. The Sites.
Resources. Products. FAQs. Tutorials. Magazines. Java Applets. Multimedia. Newsgroups.
Introduction. Abbreviating Binary Numbers as Octal Numbers and Hexadecimal Numbers. Converting Octal Numbers and Hexadecimal Numbers to Binary Numbers. Converting from Binary, Octal, or Hexadecimal to Decimal. Converting from Decimal to Binary, Octal, or Hexadecimal. Negative Binary Numbers: Two's Complement Notation.
Introduction. Documentation Comments. Documenting Java Source Code. javadoc. Files Produced by javadoc.
Introduction. Events. Listeners. Component Diagrams Revisited.
Introduction. Class ElevatorModel. Classes Location and Floor. Class Door. Class Button. Class ElevatorShaft. Classes Light and Bell. Class Elevator. Class Person. Component Diagrams Revisited. Conclusion.
Introduction. Class Objects. Class Constants. Class constructor. Event Handling. Component Diagrams Revisited. Conclusion.
Introduction. Resources for the Job Seeker. Online Opportunities for Employers. Recruiting Services. Career Sites. Internet and World Wide Web Resources.
Introduction. Unicode Transformation Formats. Characters and Glyphs. Advantages/Disadvantages of Unicode. Unicode Consortium's Web Site. Using Unicode. Character Ranges.
Live in fragments no longer. Only connect.
Edward Morgan Forster
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 publisherPrentice 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.
This edition contains many new features and enhancements including:
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 programmingsomething 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 clearproduce 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 of Java How to Program
Java 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 Program. Hundreds of thousands of university students and professional people worldwide have learned C, C++ and Java from these texts. Upon publication in August, 2001 Java How to Program, Fourth Edition will be used in hundreds of universities and thousands of corporations and government organizations worldwide. Deitel & Associates, Inc. taught Java courses internationally to thousands of students as we were writing the various editions of Java How to Program. We carefully monitored the effectiveness of these courses and tuned the material accordingly.
Conceptualization of Java
We believe in Java. Its conceptualization (and public release in 1995) by Sun Microsystems, the creators of Java, was brilliant. Sun based the new language on two of the world's most widely used implementation languages, C and C++. This immediately gave Java a huge pool of highly skilled programmers who were implementing most of the world's new operating systems, communications systems, database systems, personal computer applications and systems software. Sun removed the messier, more complex and error-prone C/ C++ features (such as pointers, operator overloading and multiple inheritance, among others). They kept the language concise by removing special-purpose features that were used by only small segments of the programming community. They made the language truly portable to be appropriate for implementing Internet-based and World-Wide-Web-based applications, and they built in the features people really need such as strings, graphics, graphical user interface components, exception handling, multithreading, multimedia (audio, images, animation and video), file processing, database processing, Internet and World Wide Web-based client/server networking and distributed computing, and prepackaged data structures. Then they made the language available at no charge to millions of potential programmers worldwide.
2.5 Million Java Developers
Java was promoted in 1995 as a means of adding "dynamic content" to World-Wide-Web pages. Instead of Web pages with only text and static graphics, people's Web pages could now "come alive" with audios, videos, animations, interactivityand soon, three-dimensional imaging. But we saw much more in Java than this. Java's features are precisely what businesses and organizations need to meet today's information-processing requirements. So we immediately viewed Java as having the potential to become one of the world's key general-purpose programming languages. In fact, Java has revolutionized software development with multimedia-intensive, platform-independent, object-oriented code for conventional, Internet-, Intranet- and Extranet-based applications and applets. Java now has 2.5 million developers worldwidea stunning accomplishment given that it has only been available publicly for six years. No other programming language has ever acquired such a large developer base so quickly.
Enabling Multimedia-Based Applications and Communications
The computer field has never seen anything like the Internet/World Wide Web/Java "explosion" occurring today. People want to communicate. People need to communicate. Sure they have been doing that since the dawn of civilization, but computer communications have been mostly limited to digits, alphabetic characters and special characters. Today, we are in the midst of a multimedia revolution. People want to transmit pictures and they want those pictures to be in color. They want to transmit voices, sounds, audio clips and full-motion color video (and they want nothing less than DVD quality). Eventually, people will insist on three-dimensional, moving-image transmission. Our current flat, two-dimensional televisions will eventually be replaced with three-dimensional versions that turn our living rooms into "theaters-in-the-round." Actors will perform their roles as if we were watching live theater. Our living rooms will be turned into miniature sports stadiums. Our business offices will enable video conferencing among colleagues half a world apart as if they were sitting around one conference table. The possibilities are intriguing and Java is playing a key role in turning many of them into reality.
Java How to Program, Fourth Edition 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 edge-of-the-practice topics in industry classrooms worldwide. The text emphasizes good pedagogy.
Learning Java via the Live-Code Approach
The book is loaded with live-code examples. This is the focus of the way we teach and write about programming, and the focus of each of our multimedia Cyber Classrooms and Web-based training courses as well. Each new concept is presented in the context of a complete, working Java program (application or applet) immediately followed by one or more screen captures showing the program's output. We call this style of teaching and writing our live-code approach. We use the language to teach the language. Reading these programs (25,000+ lines of code) is much like entering and running them on a computer.
Java and Swing from Chapter Two!
Java How to Program, Fourth Edition "jumps right in" with object-oriented programming, applications and the Swing-style GUI components from Chapter 2! People tell us this is a "gutsy" move, but Java students really want to "cut to the chase." There is great stuff to be done in Java so let's get right to it! Java is not trivial by any means, but it's fun to program with and students can see immediate results. Students can get graphical, animated, multimedia-based, audio-intensive, multithreaded, database-intensive, network-based programs running quickly through Java's extensive class libraries of "reusable components." They can implement impressive projects. They are typically more creative and productive in a one- or two-semester course than in C and C++ introductory courses.
World Wide Web Access
All of the code for Java How to Program is on the CD that accompanies this book and is available on the Internet at the Deitel & Associates, Inc. Web site http://www.deitel.com. Please run each program as you read the text. Make changes to the code examples and see what happens. See how the Java compiler "complains" when you make various kinds of errors. Immediately see the effects of making changes to the code. It's a great way to learn programming by doing programming. This is copyrighted material. Feel free to use it as you study Java, but you may not republish any portion of it without explicit permission from the authors and Prentice Hall.
Objectives
Each chapter begins with a statement of objectives. This tells the student what to expect and gives the student an opportunity, after reading the chapter, to determine if he or she has met these objectives. It is a confidence builder and a source of positive reinforcement.
Quotations
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. The quotations are worth a "second look" after you read each chapter.
Outline
The chapter Outline helps the student approach the material in top-down fashion. This, too, helps students anticipate what is to come and set a comfortable and effective learning pace.
25,576 Lines of Code in 197 Example Programs (with Program Outputs)
We present Java features in the context of complete, working Java programs. The programs range from just a few lines of code to substantial examples with several hundred lines of code (and 3,465 lines of code for the optional object-oriented elevator simulator example). Students should use the program code from the CD that accompanies the book or download the code from our Web site (http://www.deitel.com) and run each program while studying that program in the text.
545 Illustrations/Figures
An abundance of charts, line drawings and program outputs is included. The discussion of control structures, for example, features carefully drawn flowcharts. Note: We do not teach flowcharting as a program development tool, but we do use a brief, flowchart-oriented presentation to specify the precise operation of each of Java's control structures.
605 Programming Tips
We have included programming tips to help students focus on important aspects of program development. We highlight hundreds of these tips in the form of Good Programming Practices, Common Programming Errors, Testing and Debugging Tips, Performance Tips, Portability Tips, Software Engineering Observations and Look-and-Feel Observations. These tips and practices represent the best we have gleaned from a combined six decades of programming and teaching experience. One of our studentsa mathematics majortold 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.
Summary (983 Summary bullets)
Each chapter ends with additional pedagogical devices. We present a thorough, bullet-list-style summary of the chapter. On average, there are 42 summary bullets per chapter. This helps the students review and reinforce key concepts.
Terminology (2171 Terms)
We include in a Terminology section an alphabetized list of the important terms defined in the chapteragain, further reinforcement. On average, there are 95 terms per chapter.
397 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. Students should be encouraged to do all the self-review exercises and check their answers.
779 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, applications and applets; 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 audiences 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 Manual CD that is available only to instructors through their Prentice-Hall representatives. NOTE: Please do not write to us requesting the instructor's manual. Distribution of this publication is strictly limited to college professors teaching from the book. Instructors may obtain the solutions manual only from their regular Prentice Hall representatives. We regret that we cannot provide the solutions to professionals. Solutions to approximately half of the exercises are included on the Java Multimedia Cyber Classroom, Fourth Edition CD, which also is part of The Complete Java 2 Training Course. For ordering instructions, please see the last few pages of this book or visit http://www.deitel.com.
Approximately 5300 Index Entries (with approximately 9500 Page References)
We have included an extensive index at the back of the book. This helps the student find any term or concept 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. The terms in the Terminology sections generally appear in the index (along with many more index items from each chapter). Students can use the index with the Terminology sections to be sure they have covered the key material of each chapter.
"Double Indexing" of Java Live-Code Examples and Exercises
Java How to Program has 197 live-code examples and 1176 exercises (including parts). Many of the exercises are challenging problems or projects requiring substantial effort. We have "double indexed" the live-code examples. For every Java source-code program in the book, we took the file name with the .java extension, such as LoadAudioAndPlay.java and indexed it both alphabetically (in this case under "L") and as a subindex item under "Examples." This makes it easier to find examples using particular features. The more substantial exercises, such as "Maze Generator and Walker," are indexed both alphabetically (in this case under "M") and as subindex items under "Exercises."
Bibliography
An extensive bibliography of books, articles and Sun Microsystems Java 2 documentation is included to encourage further reading.
There are a number of for-sale Java products available. However, you do not need them to get started with Java. We wrote Java How to Program, Fourth Edition using only the Java 2 Software Development Kit (J2SDK). For your convenience, Sun's J2SDK version 1.3.1 is included on the CD that accompanies this book. The J2SDK also can be downloaded from the Sun Microsystems Java Web site java.sun.com. With Sun's cooperation, we also were able to include on the CD a powerful Java integrated development environment (IDE)Sun Microsystems' Forté for Java Community Edition.
Forté for Java Community Edition is a professional IDE written in Java that includes a graphical user interface designer, code editor, compiler, visual debugger and more. J2SDK 1.3.1 must be installed before installing Forté for Java Community Edition. If you have any questions about using this software, please read the introductory Forté documentation on the CD. We will provide additional information on our Web site http://www.deitel.com.
The CD also contains the book's examples and an HTML Web page with links to the Deitel & Associates, Inc. Web site, the Prentice Hall Web site and the many Web sites listed in the appendices. If you have access to the Internet, this Web page can be loaded into your Web browser to give you quick access to all the resources. Finally, the CD contains Chapter 22 and Appendices E-K.
Java How to Program, Fourth Edition has extensive ancillary materials for instructors teaching from the book. The Instructor's Manual CD contains solutions to the vast majority of the end-of-chapter exercises and a test bank of multiple choice questions (approximately 2 per book section). In addition, we provide PowerPoint® slides containing all the code and figures in the text. You are free to customize these slides to meet your own classroom needs. Prentice Hall provides a Companion Web Site (http://www.prenhall.com/deitel) that includes resources for instructors and students. For instructors, the Web site has a Syllabus Manager for course planning, links to the PowerPoint slides and reference materials from the appendices of the book (such as the operator precedence chart, character sets and Web resources). For students, the Web site provides chapter objectives, true/false exercises with instant feedback, chapter highlights and reference materials. NOTE: Please do not write to us requesting the instructor's manual. Distribution of this publication is strictly limited to college professors teaching from the book. Instructors may obtain the solutions manual only from their regular Prentice Hall representatives. We regret that we cannot provide the solutions to professionals.
We have prepared an interactive, CD-based, software version of Java How to Program, Fourth Edition called the Java 2 Multimedia Cyber Classroom, Fourth Edition. It is loaded with features for learning and reference. The Cyber Classroom is wrapped with the textbook at a discount in The Complete Java 2 Training Course, Fourth Edition. If you already have the book and would like to purchase the Java 2 Multimedia Cyber Classroom, Fourth Edition separately, please visit www.informit.com/cyberclassrooms. The ISBN# for the Java 2 Multimedia Cyber Classroom, Fourth Edition is 0-13-064935-x. All Deitel Cyber Classrooms are generally available in CD and Web-based training formats.
The CD has an introduction with the authors overviewing the Cyber Classroom's features. The 197 live-code example Java programs in the textbook truly "come alive" in the Cyber Classroom. If you are viewing a program and want to execute it, you simply click on the lightning bolt icon and the program will run. You will immediately seeand hear for the audio-based multimedia programsthe program's outputs. If you want to modify a program and see and hear the effects of your changes, simply click the floppy-disk icon that causes the source code to be "lifted off' the CD and "dropped into" one of your own directories so you can edit the text, recompile the program and try out your new version. Click the audio icon and Paul Deitel will talk about the program and "walk you through" the code.
The Cyber Classroom also provides navigational aids including extensive hyperlinking. The Cyber Classroom is browser based, so it remembers recent sections you have visited and allows you to move forward or backward among these sections. The thousands of index entries are hyperlinked to their text occurrences. You can key in a term using the "find" feature and the Cyber Classroom will locate its occurrences throughout the text. The Table of Contents entries are "hot"so clicking a chapter name takes you to that chapter.
Students tell us that they particularly like the hundreds of solved problems from the textbook that are included with the Cyber Classroom. Studying and running these extra programs is a great way for students to enhance their learning experience.
Students and professional users of our Cyber Classrooms tell us they like the interactivity and that the Cyber Classroom is an effective reference because of the extensive hyperlinking and other navigational features. We received an email from a person who said that he lives "in the boonies" and cannot take a live course at a university, so the Cyber Classroom was the solution to his educational needs.
Professors tell us that their students enjoy using the Cyber Classroom, spend more time on the course and master more of the material than in textbook-only courses. We have published (and will be publishing) many other Cyber Classroom and Complete Training Course products. For a complete list of the available and forthcoming Cyber Classrooms and Complete Training Courses, see the Deitel Series page at the beginning of this book or the product listing and ordering information at the end of this book. You can also visit http://www.deitel.com or http://www.prenhall.com/deitel for more information.
Our companion bookAdvanced Java 2 Platform How to Programfocuses on the Java 2 Platform, Enterprise Edition (J2EE), presents advanced Java 2 Platform Standard Edition features and introduces the Java 2 Platform, Micro Edition (J2ME). This book is intended for developers and upper-level university students in advanced courses who already know Java and want a deeper treatment and understanding of the language. The book features our signature live-code approach of complete working programs and contains over 37,000 lines of code. The programs are more substantial than those presented in Java How to Program, Fourth Edition. The book expands the coverage of Java Database Connectivity (JDBC), remote method invocation (RMI), servlets and JavaBeans from Java How to Program, Fourth Edition. The book also covers emerging and more advanced Java technologies of concern to enterprise application developers. The Table of Contents for Advanced Java 2 Platform How to Program is: ChaptersIntroduction; Advanced Swing Graphical User Interface Components; Model-View-Controller; Graphics Programming with Java 2D and Java 3D; Case Study: A Java2D Application; JavaBeans Component Model; Security; Java Database Connectivity (JDBC); Servlets; Java Server Pages (JSP); Case Study: Servlet and JSP Bookstore; Java 2 Micro Edition (J2ME) and Wireless Internet; Remote Method Invocation (RMI); Session Enterprise JavaBeans (EJBs) and Distributed Transactions; Entity EJBs; Java Message Service (JMS) and Message-Driven EJBs; Enterprise Java Case Study: Architectural Overview; Enterprise Java Case Study: Presentation and Controller Logic; Enterprise Java Case Study: Business Logic Part 1; Enterprise Java Case Study: Business Logic Part 2; Application Servers; Jini; JavaSpaces; Jiro; Java Management Extensions (JMX); Common Object Request Broker Architecture (CORBA): Part 1; Common Object Request Broker Architecture (CORBA): Part 2; Peer-to-Peer Networking; AppendicesCreating Markup with XML; XML Document Type Definitions; XML Document Object Model (DOM); XSL: Extensible Stylesheet Language Transformations; Downloading and Installing J2EE 1.2.1; Java Community Process (JCP); Java Native Interface (JNI); Career Opportunities; Unicode.