Java™ How to Program, Seventh Edition

Book description

The Deitels' groundbreaking How to Program series offers unparalleled breadth and depth of object-oriented programming concepts and intermediate-level topics for further study. This survey of Java programming contains an extensive OOD/UML 2 case study on developing an automated teller machine. The Seventh Edition has been extensively fine-tuned and is completely up-to-date with Sun Microsystems, Inc.’s latest Java release–Java Standard Edition (Java SE) 6.

Table of contents

  1. Copyright
  2. Deitel® Series Page
  3. Preface
  4. Before You Begin
  5. Introduction to Computers, the Internet and the Web
    1. Introduction
    2. What Is a Computer?
    3. Computer Organization
    4. Early Operating Systems
    5. Personal, Distributed and Client/Server Computing
    6. The Internet and the World Wide Web
    7. Machine Languages, Assembly Languages and High-Level Languages
    8. History of C and C++
    9. History of Java
    10. Java Class Libraries
    11. Fortran, COBOL, Pascal and Ada
    12. BASIC, Visual Basic, Visual C++, C# and .NET
    13. Typical Java Development Environment
    14. Notes about Java and Java How to Program, 7/e
    15. Test-Driving a Java Application
    16. Software Engineering Case Study: Introduction to Object Technology and the UML
    17. Web 2.0
    18. Software Technologies
    19. Wrap-Up
    20. Web Resources
    21. Summary
    22. Terminology
    23. Self-Review Exercises
    24. Answers to Self-Review Exercises
    25. Exercises
  6. Introduction to Java Applications
    1. Introduction
    2. A First Program in Java: Printing a Line of Text
    3. Modifying Our First Java Program
    4. Displaying Text with printf
    5. Another Java Application: Adding Integers
    6. Memory Concepts
    7. Arithmetic
    8. Decision Making: Equality and Relational Operators
    9. (Optional) Software Engineering Case Study: Examining the Requirements Document
    10. Wrap-Up
    11. Summary
    12. Terminology
    13. Self-Review Exercises
    14. Answers to Self-Review Exercises
    15. Exercises
  7. Introduction to Classes and Objects
    1. Introduction
    2. Classes, Objects, Methods and Instance Variables
    3. Declaring a Class with a Method and Instantiating an Object of a Class
    4. Declaring a Method with a Parameter
    5. Instance Variables, set Methods and get Methods
    6. Primitive Types vs. Reference Types
    7. Initializing Objects with Constructors
    8. Floating-Point Numbers and Type double
    9. (Optional) GUI and Graphics Case Study: Using Dialog Boxes
    10. (Optional) Software Engineering Case Study: Identifying the Classes in a Requirements Document
    11. Wrap-Up
    12. Summary
    13. Terminology
    14. Self-Review Exercises
    15. Answers to Self-Review Exercises
    16. Exercises
  8. Control Statements: Part 1
    1. Introduction
    2. Algorithms
    3. Pseudocode
    4. Control Structures
    5. if Single-Selection Statement
    6. if...else Double-Selection Statement
    7. while Repetition Statement
    8. Formulating Algorithms: Counter-Controlled Repetition
    9. Formulating Algorithms: Sentinel-Controlled Repetition
    10. Formulating Algorithms: Nested Control Statements
    11. Compound Assignment Operators
    12. Increment and Decrement Operators
    13. Primitive Types
    14. (Optional) GUI and Graphics Case Study: Creating Simple Drawings
    15. (Optional) Software Engineering Case Study: Identifying Class Attributes
    16. Wrap-Up
    17. Summary
    18. Terminology
    19. Self-Review Exercises
    20. Answers to Self-Review Exercises
    21. Exercises
  9. Control Statements: Part 2
    1. Introduction
    2. Essentials of Counter-Controlled Repetition
    3. for Repetition Statement
    4. Examples Using the for Statement
    5. do...while Repetition Statement
    6. switch Multiple-Selection Statement
    7. break and continue Statements
    8. Logical Operators
    9. Structured Programming Summary
    10. (Optional) GUI and Graphics Case Study: Drawing Rectangles and Ovals
    11. (Optional) Software Engineering Case Study: Identifying Objects’ States and Activities
    12. Wrap-Up
    13. Summary
    14. Terminology
    15. Self-Review Exercises
    16. Answers to Self-Review Exercises
    17. Exercises
  10. Methods: A Deeper Look
    1. Introduction
    2. Program Modules in Java
    3. static Methods, static Fields and Class Math
    4. Declaring Methods with Multiple Parameters
    5. Notes on Declaring and Using Methods
    6. Method-Call Stack and Activation Records
    7. Argument Promotion and Casting
    8. Java API Packages
    9. Case Study: Random-Number Generation
    10. Case Study: A Game of Chance (Introducing Enumerations)
    11. Scope of Declarations
    12. Method Overloading
    13. (Optional) GUI and Graphics Case Study: Colors and Filled Shapes
    14. (Optional) Software Engineering Case Study: Identifying Class Operations
    15. Wrap-Up
    16. Summary
    17. Terminology
    18. Self-Review Exercises
    19. Answers to Self-Review Exercises
    20. Exercises
  11. Arrays
    1. Introduction
    2. Arrays
    3. Declaring and Creating Arrays
    4. Examples Using Arrays
    5. Case Study: Card Shuffling and Dealing Simulation
    6. Enhanced for Statement
    7. Passing Arrays to Methods
    8. Case Study: Class GradeBook Using an Array to Store Grades
    9. Multidimensional Arrays
    10. Case Study: Class GradeBook Using a Two-Dimensional Array
    11. Variable-Length Argument Lists
    12. Using Command-Line Arguments
    13. (Optional) GUI and Graphics Case Study: Drawing Arcs
    14. (Optional) Software Engineering Case Study: Collaboration Among Objects
    15. Wrap-Up
    16. Summary
    17. Terminology
    18. Self-Review Exercises
    19. Answers to Self-Review Exercises
    20. Exercises
    21. Special Section: Building Your Own Computer
  12. Classes and Objects: A Deeper Look
    1. Introduction
    2. Time Class Case Study
    3. Controlling Access to Members
    4. Referring to the Current Object’s Members with the this Reference
    5. Time Class Case Study: Overloaded Constructors
    6. Default and No-Argument Constructors
    7. Notes on Set and Get Methods
    8. Composition
    9. Enumerations
    10. Garbage Collection and Method finalize
    11. static Class Members
    12. static Import
    13. final Instance Variables
    14. Software Reusability
    15. Data Abstraction and Encapsulation
    16. Time Class Case Study: Creating Packages
    17. Package Access
    18. (Optional) GUI and Graphics Case Study: Using Objects with Graphics
    19. (Optional) Software Engineering Case Study: Starting to Program the Classes of the ATM System
    20. Wrap-Up
    21. Summary
    22. Terminology
    23. Self-Review Exercise
    24. Answers to Self-Review Exercise
    25. Exercises
  13. Object-Oriented Programming: Inheritance
    1. Introduction
    2. Superclasses and Subclasses
    3. protected Members
    4. Relationship between Superclasses and Subclasses
    5. Constructors in Subclasses
    6. Software Engineering with Inheritance
    7. Object Class
    8. (Optional) GUI and Graphics Case Study: Displaying Text and Images Using Labels
    9. Wrap-Up
    10. Summary
    11. Terminology
    12. Self-Review Exercises
    13. Answers to Self-Review Exercises
    14. Exercises
  14. Object-Oriented Programming: Polymorphism
    1. Introduction
    2. Polymorphism Examples
    3. Demonstrating Polymorphic Behavior
    4. Abstract Classes and Methods
    5. Case Study: Payroll System Using Polymorphism
    6. final Methods and Classes
    7. Case Study: Creating and Using Interfaces
    8. (Optional) GUI and Graphics Case Study: Drawing with Polymorphism
    9. (Optional) Software Engineering Case Study: Incorporating Inheritance into the ATM System
    10. Wrap-Up
    11. Summary
    12. Terminology
    13. Self-Review Exercises
    14. Answers to Self-Review Exercises
    15. Exercises
  15. GUI Components: Part 1
    1. Introduction
    2. Simple GUI-Based Input/Output with JOptionPane
    3. Overview of Swing Components
    4. Displaying Text and Images in a Window
    5. Text Fields and an Introduction to Event Handling with Nested Classes
    6. Common GUI Event Types and Listener Interfaces
    7. How Event Handling Works
    8. JButton
    9. Buttons That Maintain State
    10. JComboBox and Using an Anonymous Inner Class for Event Handling
    11. JList
    12. Multiple-Selection Lists
    13. Mouse Event Handling
    14. Adapter Classes
    15. JPanel Subclass for Drawing with the Mouse
    16. Key-Event Handling
    17. Layout Managers
    18. Using Panels to Manage More Complex Layouts
    19. JTextArea
    20. Wrap-Up
    21. Summary
    22. Terminology
    23. Self-Review Exercises
    24. Answers to Self-Review Exercises
    25. Exercises
  16. Graphics and Java 2D™
    1. Introduction
    2. Graphics Contexts and Graphics Objects
    3. Color Control
    4. Font Control
    5. Drawing Lines, Rectangles and Ovals
    6. Drawing Arcs
    7. Drawing Polygons and Polylines
    8. Java 2D API
    9. Wrap-Up
    10. Summary
    11. Terminology
    12. Self-Review Exercises
    13. Answers to Self-Review Exercises
    14. Exercises
  17. Exception Handling
    1. Introduction
    2. Exception-Handling Overview
    3. Example: Divide by Zero without Exception Handling
    4. Example: Handling ArithmeticExceptions and InputMismatchExceptions
    5. When to Use Exception Handling
    6. Java Exception Hierarchy
    7. finally Block
    8. Stack Unwinding
    9. printStackTrace, getStackTrace and getMessage
    10. Chained Exceptions
    11. Declaring New Exception Types
    12. Preconditions and Postconditions
    13. Assertions
    14. Wrap-Up
    15. Summary
    16. Terminology
    17. Self-Review Exercises
    18. Answers to Self-Review Exercises
    19. Exercises
  18. Files and Streams
    1. Introduction
    2. Data Hierarchy
    3. Files and Streams
    4. Class File
    5. Sequential-Access Text Files
    6. Object Serialization
    7. Additional java.io Classes
    8. Opening Files with JFileChooser
    9. Wrap-Up
    10. Summary
    11. Terminology
    12. Self-Review Exercises
    13. Answers to Self-Review Exercises
    14. Exercises
  19. Recursion
    1. Introduction
    2. Recursion Concepts
    3. Example Using Recursion: Factorials
    4. Example Using Recursion: Fibonacci Series
    5. Recursion and the Method-Call Stack
    6. Recursion vs. Iteration
    7. Towers of Hanoi
    8. Fractals
    9. Recursive Backtracking
    10. Wrap-Up
    11. Internet and Web Resources
    12. Summary
    13. Terminology
    14. Self-Review Exercises
    15. Answers to Self-Review Exercises
    16. Exercises
  20. Searching and Sorting
    1. Introduction
    2. Searching Algorithms
    3. Sorting Algorithms
    4. Invariants
    5. Wrap-Up
    6. Summary
    7. Terminology
    8. Self-Review Exercises
    9. Answers to Self-Review Exercises
    10. Exercises
  21. Data Structures
    1. Introduction
    2. Type-Wrapper Classes for Primitive Types
    3. Autoboxing and Auto-Unboxing
    4. Self-Referential Classes
    5. Dynamic Memory Allocation
    6. Linked Lists
    7. Stacks
    8. Queues
    9. Trees
    10. Wrap-Up
    11. Summary
    12. Terminology
    13. Self-Review Exercises
    14. Answers to Self-Review Exercises
    15. Exercises
  22. Generics
    1. Introduction
    2. Motivation for Generic Methods
    3. Generic Methods: Implementation and Compile-Time Translation
    4. Additional Compile-Time Translation Issues: Methods That Use a Type Parameter as the Return Type
    5. Overloading Generic Methods
    6. Generic Classes
    7. Raw Types
    8. Wildcards in Methods That Accept Type Parameters
    9. Generics and Inheritance: Notes
    10. Wrap-Up
    11. Internet and Web Resources
    12. Summary
    13. Terminology
    14. Self-Review Exercises
    15. Answers to Self-Review Exercises
    16. Exercises
  23. Collections
    1. Introduction
    2. Collections Overview
    3. Class Arrays
    4. Interface Collection and Class Collections
    5. Lists
    6. Collections Algorithms
    7. Stack Class of Package java.util
    8. Class PriorityQueue and Interface Queue
    9. Sets
    10. Maps
    11. Properties Class
    12. Synchronized Collections
    13. Unmodifiable Collections
    14. Abstract Implementations
    15. Wrap-Up
    16. Summary
    17. Terminology
    18. Self-Review Exercises
    19. Answers to Self-Review Exercises
    20. Exercises
  24. Introduction to Java Applets
    1. Introduction
    2. Sample Applets Provided with the JDK
    3. Simple Java Applet: Drawing a String
    4. Applet Life-Cycle Methods
    5. Initializing an Instance Variable with Method init
    6. Sandbox Security Model
    7. Internet and Web Resources
    8. Wrap-Up
    9. Summary
    10. Terminology
    11. Self-Review Exercise
    12. Answers to Self-Review Exercise
    13. Exercises
  25. Multimedia: Applets and Applications
    1. Introduction
    2. Loading, Displaying and Scaling Images
    3. Animating a Series of Images
    4. Image Maps
    5. Loading and Playing Audio Clips
    6. Playing Video and Other Media with Java Media Framework
    7. Wrap-Up
    8. Web Resources
    9. Summary
    10. Terminology
    11. Self-Review Exercises
    12. Answers to Self-Review Exercises
    13. Exercises
    14. Special Section: Challenging Multimedia Projects
  26. GUI Components: Part 2
    1. Introduction
    2. JSlider
    3. Windows: Additional Notes
    4. Using Menus with Frames
    5. JPopupMenu
    6. Pluggable Look-and-Feel
    7. JDesktopPane and JInternalFrame
    8. JTabbedPane
    9. Layout Managers: BoxLayout and GridBagLayout
    10. Wrap-Up
    11. Summary
    12. Terminology
    13. Self-Review Exercises
    14. Answers to Self-Review Exercises
    15. Exercises
  27. Multithreading
    1. Introduction
    2. Thread States: Life Cycle of a Thread
    3. Thread Priorities and Thread Scheduling
    4. Creating and Executing Threads
    5. Thread Synchronization
    6. Producer/Consumer Relationship without Synchronization
    7. Producer/Consumer Relationship: ArrayBlockingQueue
    8. Producer/Consumer Relationship with Synchronization
    9. Producer/Consumer Relationship: Bounded Buffers
    10. Producer/Consumer Relationship: The Lock and Condition Interfaces
    11. Multithreading with GUI
    12. Other Classes and Interfaces in java.util.concurrent
    13. Wrap-Up
    14. Summary
    15. Terminology
    16. Self-Review Exercises
    17. Answers to Self-Review Exercises
    18. Exercises
  28. Networking
    1. Introduction
    2. Manipulating URLs
    3. Reading a File on a Web Server
    4. Establishing a Simple Server Using Stream Sockets
    5. Establishing a Simple Client Using Stream Sockets
    6. Client/Server Interaction with Stream Socket Connections
    7. Connectionless Client/Server Interaction with Datagrams
    8. Client/Server Tic-Tac-Toe Using a Multithreaded Server
    9. Security and the Network
    10. [Web Bonus] Case Study: DeitelMessenger Server and Client
    11. Wrap-Up
    12. Summary
    13. Terminology
    14. Self-Review Exercises
    15. Answers to Self-Review Exercises
    16. Exercises
  29. Accessing Databases with JDBC
    1. Introduction
    2. Relational Databases
    3. Relational Database Overview: The books Database
    4. SQL
    5. Instructions for installing MySQL and MySQL Connector/J
    6. Instructions for Setting Up a MySQL User Account
    7. Creating Database books in MySQL
    8. Manipulating Databases with JDBC
    9. RowSet Interface
    10. Java DB/Apache Derby
    11. PreparedStatements
    12. Stored Procedures
    13. Transaction Processing
    14. Wrap-Up
    15. Web Resources and Recommended Readings
    16. Summary
    17. Terminology
    18. Self-Review Exercise
    19. Answers to Self-Review Exercise
    20. Exercises
  30. Web Applications: Part 1
    1. Introduction
    2. Simple HTTP Transactions
    3. Multitier Application Architecture
    4. Java Web Technologies
    5. Creating and Running a Simple Application in Java Studio Creator 2
    6. JSF Components
    7. Session Tracking
    8. Wrap-Up
    9. Web Resources
    10. Summary
    11. Terminology
    12. Self-Review Exercises
    13. Answers to Self-Review Exercises
    14. Exercises
  31. Web Applications: Part 2
    1. Introduction
    2. Accessing Databases in Web Applications
    3. Ajax-Enabled JSF Components
    4. AutoComplete Text Field and Virtual Forms
    5. Google Maps Map Viewer Component
    6. Wrap-Up
    7. Web Resources
    8. Summary
    9. Terminology
    10. Self-Review Exercises
    11. Answers to Self-Review Exercises
    12. Exercises
  32. JAX-WS Web Services, Web 2.0 and Mash-Ups
    1. Introduction
    2. Java Web Services Basics
    3. Creating, Publishing, Testing and Describing a Web Service
    4. Consuming a Web Service
    5. SOAP
    6. Session Tracking in Web Services
    7. Consuming a Database-Driven Web Service from a Web Application
    8. Passing an Object of a User-Defined Type to a Web Service
    9. Wrap-Up
    10. Web Resources
    11. Summary
    12. Terminology
    13. Self-Review Exercises
    14. Answers to Self-Review Exercises
    15. Exercises
  33. Formatted Output
    1. Introduction
    2. Streams
    3. Formatting Output with printf
    4. Printing Integers
    5. Printing Floating-Point Numbers
    6. Printing Strings and Characters
    7. Printing Dates and Times
    8. Other Conversion Characters
    9. Printing with Field Widths and Precisions
    10. Using Flags in the printf Format String
    11. Printing with Argument Indices
    12. Printing Literals and Escape Sequences
    13. Formatting Output with Class Formatter
    14. Wrap-Up
    15. Summary
    16. Terminology
    17. Self-Review Exercises
    18. Answers to Self-Review Exercises
    19. Exercises
  34. Strings, Characters and Regular Expressions
    1. Introduction
    2. Fundamentals of Characters and Strings
    3. Class String
    4. Class StringBuilder
    5. Class Character
    6. Class StringTokenizer
    7. Regular Expressions, Class Pattern and Class Matcher
    8. Wrap-Up
    9. Summary
    10. Terminology
    11. Self-Review Exercises
    12. Answers to Self-Review Exercises
    13. Exercises
    14. Special Section: Advanced String-Manipulation Exercises
    15. Special Section: Challenging String-Manipulation Projects
  35. Operator Precedence Chart
    1. Operator Precedence
  36. ASCII Character Set
  37. Keywords and Reserved Words
  38. Primitive Types
  39. Number Systems
    1. Introduction
    2. Abbreviating Binary Numbers as Octal and Hexadecimal Numbers
    3. Converting Octal and Hexadecimal Numbers to Binary Numbers
    4. Converting from Binary, Octal or Hexadecimal to Decimal
    5. Converting from Decimal to Binary, Octal or Hexadecimal
    6. Negative Binary Numbers: Two’s Complement Notation
    7. Summary
    8. Terminology
    9. Self-Review Exercises
    10. Answers to Self-Review Exercises
    11. Exercises
  40. GroupLayout
    1. Introduction
    2. GroupLayout Basics
    3. Building a ColorChooser
    4. GroupLayout Web Resources
  41. Java Desktop Integration Components (JDIC)
    1. Introduction
    2. Splash Screens
    3. Desktop Class
    4. Tray Icons
    5. JDIC Incubator Projects
    6. JDIC Demos
  42. Mashups
    1. Introduction
    2. Popular Mashups
    3. APIs Commonly Used in Mashups
    4. Deitel Mashups Research Center
    5. Deitel RSS Resource Center
    6. Mashup Performance and Reliability Issues
    7. Mashup Tutorials
    8. Mashup Directories
    9. Mashup Resources
    10. Mashup Tools and Downloads
    11. Mashup Articles
    12. Mashups in the Blogosphere
    13. Mashup FAQs and Newsgroups
  43. Unicode®
    1. Introduction
    2. Unicode Transformation Formats
    3. Characters and Glyphs
    4. Advantages/Disadvantages of Unicode
    5. Unicode Consortium’s Web Site
    6. Using Unicode
    7. Character Ranges
  44. Using the Java API Documentation
    1. Introduction
  45. Creating Documentation with javadoc
    1. Introduction
    2. Documentation Comments
    3. Documenting Java Source Code
    4. javadoc
    5. Files Produced by javadoc
  46. Bit Manipulation
    1. Introduction
    2. Bit Manipulation and the Bitwise Operators
    3. BitSet Class
    4. Self-Review Exercises
    5. Answers to Self-Review Exercises
    6. Exercises
  47. ATM Case Study Code
    1. ATM Case Study Implementation
    2. Class ATM
    3. Class Screen
    4. Class Keypad
    5. Class CashDispenser
    6. Class DepositSlot
    7. Class Account
    8. Class BankDatabase
    9. Class Transaction
    10. Class BalanceInquiry
    11. Class Withdrawal
    12. Class Deposit
    13. Class ATMCaseStudy
    14. Wrap-Up
  48. Labeled break and continue Statements
    1. Introduction
    2. Labeled break Statement
    3. Labeled continue Statement
  49. UML 2:Additional Diagram Types
    1. Introduction
    2. Additional Diagram Types
  50. Design Patterns
    1. Introduction
    2. Creational, Structural and Behavioral Design Patterns
    3. Design Patterns in Packages java.awt and javax.swing
    4. Concurrency Design Patterns
    5. Design Patterns Used in Packages java.io and java.net
    6. Design Patterns Used in Package java.util
    7. Wrap-Up
    8. Web Resources
  51. Using the Debugger
    1. Introduction
    2. Breakpoints and the run, stop cont and print Commands
    3. The print and set Commands
    4. Controlling Execution Using the step, step up and next Commands
    5. The watch Command
    6. The clear Command
    7. Wrap-Up
    8. Self-Review Exercises
    9. Answers to Self-Review Exercises
  52. Index

Product information

  • Title: Java™ How to Program, Seventh Edition
  • Author(s): H. M. Deitel - Deitel & Associates, Inc., P. J. Deitel - Deitel & Associates, Inc.
  • Release date: December 2006
  • Publisher(s): Pearson
  • ISBN: 9780136085676