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. Their Live Code Approach features thousands of lines of code in hundreds of complete working programs. This enables readers to confirm that programs run as expected. Java How to Program (Early Objects) 9e contains an optional extensive OOD/UML 2 case study on developing and implementing the software for an automated teller machine.This edition covers both Java SE7 and SE6.
Appendices M, N, O, P, and Q are available at Java How to Program, 9/e's Companion Website (www.pearsonhighered.com/deitel) as PDF documents.
Table of contents
- Java™ How to Program
- Deitel® Series Page
- Java™ How to Program
- Trademarks
- Preface
- Before You Begin
-
1 Introduction to Computers and Java
- Objectives
- Outline
- 1.1 Introduction
- 1.2 Computers: Hardware and Software
- 1.3 Data Hierarchy
- 1.4 Computer Organization
- 1.5 Machine Languages, Assembly Languages and High-Level Languages
- 1.6 Introduction to Object Technology
- 1.7 Operating Systems
- 1.8 Programming Languages
- 1.9 Java and a Typical Java Development Environment
- Phase 1: Creating a Program
- Phase 2: Compiling a Java Program into Bytecodes
- Phase 3: Loading a Program into Memory
- Phase 4: Bytecode Verification
- Phase 5: Execution
- Problems That May Occur at Execution Time
- 1.10 Test-Driving a Java Application
- 1.11 Web 2.0: Going Social
- 1.13 Keeping Up-to-Date with Information Technologies
- 1.14 Wrap-Up
- Self-Review Exercises
- Exercises
- Making a Difference
- Making a Difference Resources
-
2 Introduction to Java Applications
- Objectives
- Outline
- 2.1 Introduction
- 2.2 Your First Program in Java: Printing a Line of Text
- 2.3 Modifying Your First Java Program
- 2.4 Displaying Text with printf
-
2.5 Another Application: Adding Integers
- Import Declarations
- Declaring Class Addition
- Declaring and Creating a Scanner to Obtain User Input from the Keyboard
- Declaring Variables to Store Integers
- Prompting the User for Input
- Obtaining an int as Input from the User
- Prompting for and Inputting a Second int
- Using Variables in a Calculation
- Displaying the Result of the Calculation
- Java API Documentation
- 2.6 Memory Concepts
- 2.7 Arithmetic
- 2.8 Decision Making: Equality and Relational Operators
- 2.9 Wrap-Up
-
Summary
- Section 2.2 Your First Program in Java: Printing a Line of Text
- Section 2.3 Modifying Your First Java Program
- Section 2.4 Displaying Text with printf
- Section 2.5 Another Application: Adding Integers
- Section 2.6 Memory Concepts
- Section 2.7 Arithmetic
- Section 2.8 Decision Making: Equality and Relational Operators
- Self-Review Exercises
- Exercises
- Making a Difference
-
3 Introduction to Classes, Objects, Methods and strings
- Objectives
- Outline
- 3.1 Introduction
- 3.2 Declaring a Class with a Method and Instantiating an Object of a Class
- 3.3 Declaring a Method with a Parameter
-
3.4 Instance Variables, set Methods and get Methods
- GradeBook Class with an Instance Variable, a set Method and a get Method
- Access Modifiers public and private
- Methods setCourseName and getCourseName
- Method displayMessage
- GradeBookTest Class That Demonstrates Class GradeBook
- set and get Methods
- GradeBook UML Class Diagram with an Instance Variable and set and get Methods
- 3.5 Primitive Types vs. Reference Types
- 3.6 Initializing Objects with Constructors
- 3.7 Floating-Point Numbers and Type double
- 3.8 (Optional) GUI and Graphics Case Study: Using Dialog Boxes
- 3.9 Wrap-Up
-
Summary
- Section 3.2 Declaring a Class with a Method and Instantiating an Object of a Class
- Section 3.3 Declaring a Method with a Parameter
- Section 3.4 Instance Variables, set Methods and get Methods
- Section 3.5 Primitive Types vs. Reference Types
- Section 3.6 Initializing Objects with Constructors
- Section 3.7 Floating-Point Numbers and Type double
- Self-Review Exercises
- Exercises
- Making a Difference
-
4 Control Statements: Part 1
- Objectives
- Outline
- 4.1 Introduction
- 4.2 Algorithms
- 4.3 Pseudocode
- 4.4 Control Structures
- 4.5 if Single-Selection Statement
- 4.6 if…else Double-Selection Statement
- 4.7 while Repetition Statement
- 4.8 Formulating Algorithms: Counter-Controlled Repetition
-
4.9 Formulating Algorithms: Sentinel-Controlled Repetition
- Developing the Pseudocode Algorithm with Top-Down, Stepwise Refinement: The Top and First Refinement
- Proceeding to the Second Refinement
- Implementing Sentinel-Controlled Repetition in Class GradeBook
- Program Logic for Sentinel-Controlled Repetition vs. Counter-Controlled Repetition
- Explicitly and Implicitly Converting Between Primitive Types
- 4.10 Formulating Algorithms: Nested Control Statements
- 4.11 Compound Assignment Operators
- 4.12 Increment and Decrement Operators
- 4.13 Primitive Types
- 4.14 (Optional) GUI and Graphics Case Study: Creating Simple Drawings
- 4.15 Wrap-Up
-
Summary
- Section 4.1 Introduction
- Section 4.2 Algorithms
- Section 4.3 Pseudocode
- Section 4.4 Control Structures
- Section 4.5 if Single-Selection Statement
- Section 4.6 if…else Double-Selection Statement
- Section 4.7 while Repetition Statement
- Section 4.8 Formulating Algorithms: Counter-Controlled Repetition
- Section 4.9 Formulating Algorithms: Sentinel-Controlled Repetition
- Section 4.11 Compound Assignment Operators
- Section 4.12 Increment and Decrement Operators
- Section 4.13 Primitive Types
- Self-Review Exercises
- Exercises
- Making a Difference
-
5 Control Statements: Part 2
- Objectives
- Outline
- 5.1 Introduction
- 5.2 Essentials of Counter-Controlled Repetition
-
5.3 for Repetition Statement
- A Closer Look at the for Statement’s Header
- General Format of a for Statement
- Representing a for Statement with an Equivalent while statement
- Scope of a for Statement’s Control Variable
- Expressions in a for Statement’s Header Are Optional
- Placing Arithmetic Expressions in a for Statement’s Header
- Using a for Statement’s Control Variable in the Statements’s Body
- UML Activity Diagram for the for Statement
- 5.4 Examples Using the for Statement
- 5.5 do…while Repetition Statement
-
5.6 switch Multiple-Selection Statement
- GradeBook Class with switch Statement to Count A, B, C, D and F Grades
- Method inputGrades
- Method incrementLetterGradeCounter
- GradeBookTest Class That Demonstrates Class GradeBook
- switch statement UML Activity Diagram
- Notes on the Expression in Each case of a switch
- Using strings in switch statements (New in Java SE 7)
- 5.7 break and continue Statements
- 5.8 Logical Operators
- 5.9 Structured Programming Summary
- 5.10 (Optional) GUI and Graphics Case Study: Drawing Rectangles and Ovals
- 5.11 Wrap-Up
- Summary
- Self-Review Exercises
- Exercises
- Making a Difference
-
6 Methods: A Deeper Look
- Objectives
- Outline
- 6.1 Introduction
- 6.2 Program Modules in Java
- 6.3 static Methods, static Fields and Class Math
- 6.4 Declaring Methods with Multiple Parameters
- 6.5 Notes on Declaring and Using Methods
- 6.6 Method-Call Stack and Activation Records
- 6.7 Argument Promotion and Casting
- 6.8 Java API Packages
- 6.9 Case Study: Random-Number Generation
- 6.10 Case Study: A Game of Chance; Introducing Enumerations
- 6.11 Scope of Declarations
- 6.12 Method Overloading
- 6.13 (Optional) GUI and Graphics Case Study: Colors and Filled Shapes
- 6.14 Wrap-Up
-
Summary
- Section 6.1 Introduction
- Section 6.2 Program Modules in Java
- Section 6.3 static Methods, static Fields and Class Math
- Section 6.4 Declaring Methods with Multiple Parameters
- Section 6.5 Notes on Declaring and Using Methods
- Section 6.6 Method-Call Stack and Activation Records
- Section 6.7 Argument Promotion and Casting
- Section 6.9 Case Study: Random-Number Generation
- Section 6.10 Case Study: A Game of Chance; Introducing Enumerations
- Section 6.11 Scope of Declarations
- Section 6.12 Method Overloading
- Self-Review Exercises
- Exercises
- Making a Difference
-
7 Arrays and ArrayLists
- Objectives
- Outline
- 7.1 Introduction
- 7.2 Arrays
- 7.3 Declaring and Creating Arrays
-
7.4 Examples Using Arrays
- Creating and Initializing an Array
- Using an Array Initializer
- Calculating the Values to Store in an Array
- Summing the Elements of an Array
- Using Bar Charts to Display Array Data Graphically
- Using the Elements of an Array as Counters
- The frequency Array
- Summarizing the Results
- Exception Handling: Processing the Incorrect Response
- The try Statement
- Executing the catch Block
- toString Method of the Exception Parameter
- 7.5 Case Study: Card Shuffling and Dealing Simulation
- 7.6 Enhanced for Statement
- 7.7 Passing Arrays to Methods
- 7.8 Case Study: Class GradeBook Using an Array to Store Grades
- 7.9 Multidimensional Arrays
- 7.10 Case Study: Class GradeBook Using a Two-Dimensional Array
- 7.11 Variable-Length Argument Lists
- 7.12 Using Command-Line Arguments
- 7.13 Class Arrays
- 7.14 Introduction to Collections and Class ArrayList
- 7.15 (Optional) GUI and Graphics Case Study: Drawing Arcs
- 7.16 Wrap-Up
- Summary
- Section 7.1 Introduction
- Section 7.2 Arrays
- Section 7.3 Declaring and Creating Arrays
- Section 7.4 Examples Using Arrays
- Section 7.5 Case Study: Card Shuffling and Dealing Simulation
- Section 7.6 Enhanced for Statement
- Section 7.7 Passing Arrays to Methods
- Section 7.9 Multidimensional Arrays
- Section 7.11 Variable-Length Argument Lists
- Section 7.12 Using Command-Line Arguments
- Section 7.13 Class Arrays
- Section 7.14 Introduction to Collections and Class ArrayList
- Self-Review Exercises
- 7.4
- 7.5
- Exercises
- Exercises 7.30–7.33 are reasonably challenging. Once you’ve done them, you ought to be able to implement most popular card games easily.
- Special Section: Building Your Own Computer
- Making a Difference
-
8 Classes and Objects: A Deeper Look
- Objectives
- Outline
- 8.1 Introduction
- 8.2 Time Class Case Study
- 8.3 Controlling Access to Members
- 8.4 Referring to the Current Object’s Members with the this Reference
- 8.5 Time Class Case Study: Overloaded Constructors
- 8.6 Default and No-Argument Constructors
- 8.7 Notes on Set and Get Methods
- 8.8 Composition
- 8.9 Enumerations
- 8.10 Garbage Collection and Method finalize
- 8.11 static Class Members
- Tracking the Number of Employee Objects That Have Been Created
- 8.12 static Import
- 8.13 final Instance Variables
- 8.14 Time Class Case Study: Creating Packages
- 8.15 Package Access
- 8.16 (Optional) GUI and Graphics Case Study: Using Objects with Graphics
- Class MyLine
- Class DrawPanel
- Class TestDraw
- GUI and Graphics Case Study Exercise
- 8.17 Wrap-Up
-
Summary
- Section 8.2 Time Class Case Study
- Section 8.3 Controlling Access to Members
- Section 8.4 Referring to the Current Object’s Members with the this Reference
- Section 8.5 Time Class Case Study: Overloaded Constructors
- Section 8.6 Default and No-Argument Constructors
- Section 8.7 Notes on Set and Get Methods
- Section 8.8 Composition
- Section 8.9 Enumerations
- Section 8.10 Garbage Collection and Method finalize
- Section 8.11 static Class Members
- Section 8.12 static Import
- Section 8.13 final Instance Variables
- Section 8.14 Time Class Case Study: Creating Packages
- 8.15 Package Access
- Self-Review Exercise
- Exercises
- Making a Difference
-
9 Object-Oriented Programming: Inheritance
- Objectives
- Outline
- 9.1 Introduction
- 9.2 Superclasses and Subclasses
- 9.3 protected Members
-
9.4 Relationship between Superclasses and Subclasses
- 9.4.1 Creating and Using a CommissionEmployee Class
- 9.4.2 Creating and Using a BasePlusCommissionEmployee Class
- 9.4.3 Creating a CommissionEmployee–BasePlusCommissionEmployee Inheritance Hierarchy
- 9.4.4 CommissionEmployee–BasePlusCommissionEmployee Inheritance Hierarchy Using protected Instance Variables
- 9.4.5 CommissionEmployee–BasePlusCommissionEmployee Inheritance Hierarchy Using private Instance Variables
- 9.5 Constructors in Subclasses
- 9.6 Software Engineering with Inheritance
- 9.7 Class Object
- 9.8 (Optional) GUI and Graphics Case Study: Displaying Text and Images Using Labels
- 9.9 Wrap-Up
- Summary
- Self-Review Exercises
- Exercises
-
10 Object-Oriented Programming: Polymorphism
- Objectives
- Outline
- 10.1 Introduction
- 10.2 Polymorphism Examples
- 10.3 Demonstrating Polymorphic Behavior
- 10.4 Abstract Classes and Methods
-
10.5 Case Study: Payroll System Using Polymorphism
- 10.5.1 Abstract Superclass Employee
- 10.5.2 Concrete Subclass SalariedEmployee
- 10.5.3 Concrete Subclass HourlyEmployee
- 10.5.4 Concrete Subclass CommissionEmployee
- 10.5.5 Indirect Concrete Subclass BasePlusCommissionEmployee
- 10.5.6 Polymorphic Processing, Operator instanceof and Downcasting
- 10.5.7 Summary of the Allowed Assignments Between Superclass and Subclass Variables
- 10.6 final Methods and Classes
-
10.7 Case Study: Creating and Using Interfaces
- Standardizing Interactions
- Software Objects Communicate Via Interfaces
- Relating Disparate Types
- Interfaces vs. Abstract Classes
-
Tagging Interfaces
- 10.7.1 Developing a Payable Hierarchy
- 10.7.2 Interface Payable
- 10.7.3 Class Invoice
- 10.7.4 Modifying Class Employee to Implement Interface Payable
- 10.7.5 Modifying Class SalariedEmployee for Use in the Payable Hierarchy
- 10.7.6 Using Interface Payable to Process Invoices and Employees Polymorphically
- 10.7.7 Common Interfaces of the Java API
- 10.8 (Optional) GUI and Graphics Case Study: Drawing with Polymorphism
- 10.9 Wrap-Up
- Summary
- Self-Review Exercises
- Exercises
- Making a Difference
-
11 Exception Handling: A Deeper Look
- Objectives
- Outline
- 11.1 Introduction
- 11.2 Example: Divide by Zero without Exception Handling
- 11.3 Example: Handling ArithmeticExceptions and InputMismatchExceptions
- 11.4 When to Use Exception Handling
- 11.5 Java Exception Hierarchy
- 11.6 finally Block
- 11.7 Stack Unwinding and Obtaining Information from an Exception Object
- 11.8 Chained Exceptions
- 11.9 Declaring New Exception Types
- 11.10 Preconditions and Postconditions
- 11.11 Assertions
- 11.12 (New in Java SE 7) Multi-catch: Handling Multiple Exceptions in One catch
- 11.13 (New in Java SE 7) try-with-Resources: Automatic Resource Deallocation
- 11.14 Wrap-Up
-
Summary
- Section 11.1 Introduction
- Section 11.2 Example: Divide by Zero without Exception Handling
- Section 11.3 Example: Handling ArithmeticExceptions and InputMismatchExceptions
- Section 11.4 When to Use Exception Handling
- Section 11.5 Java Exception Hierarchy
- Section 11.6 finally block
- Section 11.7 Stack Unwinding and Obtaining Information from an Exception Object
- Section 11.8 Chained Exceptions
- Section 11.9 Declaring New Exception Types
- Section 11.10 Preconditions and Postconditions
- Section 11.11 Assertions
- Section 11.12 Multi-catch: Handling Multiple Exceptions in One catch
- Section 11.13 try-with-Resources: Automatic Resource Deallocation
- Self-Review Exercises
- Exercises
-
12 ATM Case Study, Part 1: Object-Oriented Design with the UML
- Objectives
- Outline
- 12.1 Case Study Introduction
- 12.2 Examining the Requirements Document
- Self-Review Exercises for Section 12.2
- 12.3 Identifying the Classes in a Requirements Document
- Self-Review Exercises for Section 12.3
- 12.4 Identifying Class Attributes
- Self-Review Exercises for Section 12.4
- 12.5 Identifying Objects’ States and Activities
- Self-Review Exercises for Section 12.5
-
12.6 Identifying Class Operations
- Modeling Operations
- Authenticating a User
- Other BankDatabase and Account Operations
- Getting the Balances
- Crediting and Debiting an Account
- Deposit Confirmations Performed by Another Banking System
- Displaying Messages
- Keyboard Input
- Dispensing Cash
- Class ATM
- Identifying and Modeling Operation Parameters for Class BankDatabase
- Identifying and Modeling Operation Parameters for Class Account
- Identifying and Modeling Operation Parameters for Class Screen
- Identifying and Modeling Operation Parameters for Class CashDispenser
- Identifying and Modeling Operation Parameters for Other Classes
- Self-Review Exercises for Section 12.6
- 12.7 Indicating Collaboration Among Objects
- Self-Review Exercises for Section 12.7
- 12.8 Wrap-Up
-
13 ATM Case Study Part 2: Implementing an Object-Oriented Design
- Objectives
- Outline
- 13.1 Introduction
- 13.2 Starting to Program the Classes of the ATM System
- Self-Review Exercises for Section 13.2
- 13.3 Incorporating Inheritance and Polymorphism into the ATM System
- Self-Review Exercises for Section 13.3
- 13.4 ATM Case Study Implementation
- 13.5 Wrap-Up
-
14 GUI Components: Part 1
- Objectives
- Outline
- 14.1 Introduction
- 14.2 Java’s New Nimbus Look-and-Feel
- 14.3 Simple GUI-Based Input/Output with JOptionPane
- 14.4 Overview of Swing Components
- 14.5 Displaying Text and Images in a Window
- 14.6 Text Fields and an Introduction to Event Handling with Nested Classes
- 14.7 Common GUI Event Types and Listener Interfaces
- 14.8 How Event Handling Works
- 14.9 JButton
- 14.10 Buttons That Maintain State
- 14.11 JComboBox; Using an Anonymous Inner Class for Event Handling
- 14.12 JList
- 14.13 Multiple-Selection Lists
- 14.14 Mouse Event Handling
- 14.15 Adapter Classes
- 14.16 JPanel Subclass for Drawing with the Mouse
- 14.17 Key Event Handling
- 14.18 Introduction to Layout Managers
- 14.19 Using Panels to Manage More Complex Layouts
- 14.20 JTextArea
- 14.21 Wrap-Up
-
Summary
- Section 14.1 Introduction
- Section 14.2 Java’s New Nimbus Look-and-Feel
- Section 14.3 Simple GUI-Based Input/Output with JOptionPane
- Section 14.4 Overview of Swing Components
- Section 14.5 Displaying Text and Images in a Window
- Section 14.6 Text Fields and an Introduction to Event Handling with Nested Classes
- Section 14.7 Common GUI Event Types and Listener Interfaces
- Section 14.8 How Event Handling Works
- Section 14.9 JButton
- Section 14.10 Buttons That Maintain State
- Section 14.11 JComboBox and Using an Anonymous Inner Class for Event Handling
- Section 14.12 JList
- Section 14.13 Multiple-Selection Lists
- Section 14.14 Mouse Event Handling
- Section 14.15 Adapter Classes
- Section 14.16 JPanel Subclass for Drawing with the Mouse
- Section 14.17 Key Event Handling
- Section 14.18 Introduction to Layout Managers
- Section 14.19 Using Panels to Manage More Complex Layouts
- Section 14.20 JTextArea
- Self-Review Exercises
- Exercises
- Making a Difference
-
15 Graphics and Java 2D
- Objectives
- Outline
- 15.1 Introduction
- 15.2 Graphics Contexts and Graphics Objects
- 15.3 Color Control
- 15.4 Manipulating Fonts
- 15.5 Drawing Lines, Rectangles and Ovals
- 15.6 Drawing Arcs
- 15.7 Drawing Polygons and Polylines
- 15.8 Java 2D API
- 15.9 Wrap-Up
- Summary
- Self-Review Exercises
- Exercises
- Making a Difference
-
16 Strings, Characters and Regular Expressions
- Objectives
- Outline
- 16.1 Introduction
- 16.2 Fundamentals of Characters and Strings
- 16.4 Class StringBuilder
- 16.5 Class Character
- 16.6 Tokenizing Strings
- 16.7 Regular Expressions, Class Pattern and Class Matcher
- 16.8 Wrap-Up
- Summary
- Self-Review Exercises
- Exercises
- Special Section: Advanced string-Manipulation Exercises
- Special Section: Challenging string-Manipulation Projects
- Making a Difference
-
17 Files, Streams and Object Serialization
- Objectives
- Outline
- 17.1 Introduction1
- 17.2 Files and Streams
- 17.3 Class File
- 17.4 Sequential-Access Text Files
- 17.5 Object Serialization
- 17.6 Additional java.io Classes
- 17.7 Opening Files with JFileChooser
- 17.8 Wrap-Up
- Summary
- Self-Review Exercises
- Exercises
- Making a Difference
-
18 Recursion
- Objectives
- Outline
- 18.1 Introduction
- 18.2 Recursion Concepts
- 18.3 Example Using Recursion: Factorials
- 18.4 Example Using Recursion: Fibonacci Series
- 18.6 Recursion vs. Iteration
- 18.8 Fractals
- 18.9 Recursive Backtracking
- 18.10 Wrap-Up
-
Summary
- Section 18.1 Introduction
- Section 18.2 Recursion Concepts
- Section 18.3 Example Using Recursion: Factorials
- Section 18.4 Example Using Recursion: Fibonacci Series
- Section 18.5 Recursion and the Method-Call Stack
- Section 18.6 Recursion vs. Iteration
- Section 18.8 Fractals
- Section 18.9 Recursive Backtracking
- Self-Review Exercises
- Exercises
- 19 Searching, Sorting and Big O
-
20 Generic Collections
- Objectives
- Outline
- 20.1 Introduction
- 20.2 Collections Overview
- 20.3 Type-Wrapper Classes for Primitive Types
- 20.4 Autoboxing and Auto-Unboxing
- 20.5 Interface Collection and Class Collections
- 20.6 Lists
- 20.7 Collections Methods
- 20.8 Stack Class of Package java.util
- 20.9 Class PriorityQueue and Interface Queue
- 20.10 Sets
- 20.11 Maps
- 20.12 Properties Class
- 20.13 Synchronized Collections
- 20.14 Unmodifiable Collections
- 20.15 Abstract Implementations
- 20.16 Wrap-Up
-
Summary
- Section 20.1 Introduction
- Section 20.2 Collections Overview
- Section 20.3 Type-Wrapper Classes for Primitive Types
- Section 20.4 Autoboxing and Auto-Unboxing
- Section 20.5 Interface Collection and Class Collections
- Section 20.6 Lists
- Section 20.7 Collections Methods
- Section 20.8 Stack Class of Package java.util
- Section 20.9 Class PriorityQueue and Interface Queue
- Section 20.10 Sets
- Section 20.11 Maps
- Section 20.12 Properties Class
- Section 20.13 Synchronized Collections
- Section 20.14 Unmodifiable Collections
- Section 20.15 Abstract Implementations
- Self-Review Exercises
- Execises
-
21 Generic Classes and Methods
- Objectives
- Outline
- 21.1 Introduction
- 21.2 Motivation for Generic Methods
- 21.3 Generic Methods: Implementation and Compile-Time Translation
- 21.5 Overloading Generic Methods
- 21.6 Generic Classes
- 21.7 Raw Types
- 21.8 Wildcards in Methods That Accept Type Parameters
- 21.10 Wrap-Up
-
Summary
- Section 21.1 Introduction
- Section 21.2 Motivation for Generic Methods
- Section 21.3 Generic Methods: Implementation and Compile-Time Translation
- Section 21.4 Additional Compile-Time Translation Issues: Methods That Use a Type Parameter as the Return Type
- Section 21.5 Overloading Generic Methods
- Section 21.6 Generic Classes
- Section 21.7 Raw Types
- Section 21.8 Wildcards in Methods That Accept Type Parameters
- Section 21.9 Generics and Inheritance: Notes
- Self-Review Exercises
- Exercises
- 22 Custom Generic Data Structures
-
23 Applets and Java Web Start
- Objectives
- Outline
- 23.1 Introduction
- 23.2 Sample Applets Provided with the JDK
- 23.3 Simple Java Applet: Drawing a String
- 23.7 Java Web Start and the Java Network Launch Protocol (JNLP)
- 23.8 Wrap-Up
-
Summary
- Section 23.1 Introduction
- Section 23.2 Sample Applets Provided with the JDK
- Section 23.3 Simple Java Applet: Drawing a String
- Section 23.4 Applet Life-Cycle Methods
- Section 23.5 Initialization with Method init
- Section 23.6 Sandbox Security Model
- Section 23.7 Java Web Start and the Java Network Launch Protocol (JNLP)
- Self-Review Exercise
- Exercises
-
24 Multimedia: Applets and Applications
- Objectives
- Outline
- 24.1 Introduction
-
24.2 Loading, Displaying and Scaling Images
- Configuring the GUI and the JButton’s Event Handler
- Opening the Image File Using JNLP’s FileOpenService
- Displaying the Image with Class DrawJPanel’s paintComponent Method
- Compiling the Applet
- Packaging the Applet for Use with Java Web Start
- JNLP Document for LoadImageAndScale Applet
- Making the Applet Draggable Outside the Browser Window
- 24.3 Animating a Series of Images
- 24.4 Image Maps
- 24.5 Loading and Playing Audio Clips
- 24.7 Wrap-Up
- 24.8 Web Resources
- Summary
- Self-Review Exercises
- Exercises
- Special Section: Challenging Multimedia Projects
- Making a Difference
-
25 GUI Components: Part 2
- Objectives
- Outline
- 25.1 Introduction
- 25.2 JSlider
- 25.3 Windows: Additional Notes
- 25.4 Using Menus with Frames
- 25.5 JPopupMenu
- 25.6 Pluggable Look-and-Feel
- 25.7 JDesktopPane and JInternalFrame
- 25.8 JTabbedPane
- 25.9 Layout Managers: BoxLayout and GridBagLayout
- 25.10 Wrap-Up
- Summary
- Self-Review Exercises
- Exercises
-
26 Multithreading
- Objectives
- Outline
- 26.1 Introduction
-
26.2 Thread States: Life Cycle of a Thread
- New and Runnable States
- Waiting State
- Timed Waiting State
- Blocked State
- Terminated State
- Operating-System View of the Runnable State
- Thread Priorities and Thread Scheduling
- 26.3 Creating and Executing Threads with Executor Framework
- Creating Concurrent Tasks with the Runnable Interface
- Executing Runnable Objects with an Executor
- Implementing the Runnable Interface
- Using the ExecutorService to Manage Threads that Execute PrintTasks
- 26.4 Thread Synchronization
- 26.6 Producer/Consumer Relationship: ArrayBlockingQueue
- 26.7 Producer/Consumer Relationship with Synchronization
- 26.8 Producer/Consumer Relationship: Bounded Buffers
- 26.9 Producer/Consumer Relationship: The Lock and Condition Interfaces
- 26.10 Concurrent Collections Overview
- 26.11 Multithreading with GUI
- 26.12 Interfaces Callable and Future
- 26.13 Java SE 7: Fork/Join Framework
- 26.14 Wrap-Up
-
Summary
- Section 26.1 Introduction
- Section 26.2 Thread States: Life Cycle of a Thread
- Section 26.3 Creating and Executing Threads with Executor Framework
- Section 26.4 Thread Synchronization
- Section 26.5 Producer/Consumer Relationship without Synchronization
- Section 26.6 Producer/Consumer Relationship: ArrayBlockingQueue
- Section 26.7 Producer/Consumer Relationship with Synchronization
- Section 26.8 Producer/Consumer Relationship: Bounded Buffers
- Section 26.9 Producer/Consumer Relationship: The Lock and Condition Interfaces
- Section 26.11 Multithreading with GUI
- Section 26.12 Interfaces Callable and Future
- Section 26.13 Java SE 7: Fork/Join Framework
- Self-Review Exercises
- Exercises
-
27 Networking
- Objectives
- Outline
- 27.1 Introduction
-
27.2 Manipulating URLs
- Processing Applet Parameters
- Storing the Website Names and URLs
- Building the Applet’s GUI
- Processing a User Selection
- Specifying the Target Frame for Method showDocument
- 27.3 Reading a File on a Web Server
- 27.4 Establishing a Simple Server Using Stream Sockets
- Step 1: Create a ServerSocket
- Step 3: Get the Socket’s I/O Streams
- Step 4: Perform the Processing
- Step 5: Close the Connection
- 27.5 Establishing a Simple Client Using Stream Sockets
- Step 1: Create a Socket to Connect to the sServer
- Step 2: Get the Socket’s I/O Streams
- Step 3: Perform the Processing
- Step 4: Close the Connection
- 27.6 Client/Server Interaction with Stream Socket Connections
- 27.7 Datagrams: Connectionless Client/Server Interaction
- 27.8 Client/Server Tic-Tac-Toe Using a Multithreaded Server
- 27.9 [Web Bonus] Case Study: DeitelMessenger
- 27.10 Wrap-Up
- Summary
- Self-Review Exercises
- Exercises
-
28 Accessing Databases with JDBC
- Objectives
- Outline
- 28.1 Introduction1
- 28.2 Relational Databases
- 28.3 Relational Database Overview: The books Database
- 28.4 SQL
- 28.5 Instructions for Installing MySQL and MySQL Connector/J
- 28.6 Instructions for Setting Up a MySQL User Account
- 28.7 Creating Database books in MySQL
-
28.8 Manipulating Databases with JDBC
- 28.8.1 Connecting to and Querying a Database
-
28.8.2 Querying the books Database
- ResultSetTableModel Class
- ResultSetTableModel Constructor
- ResultSetTableModel Method getColumnClass
- ResultSetTableModel Method getColumnCount
- ResultSetTableModel Method getColumnName
- ResultSetTableModel Method getRowCount
- ResultSetTableModel Method getValueAt
- ResultSetTableModel Method setQuery
- ResultSetTableModel Method disconnectFromDatabase
- DisplayQueryResults Class
- Sorting Rows in a JTable
- Filtering Rows in a JTable
- 28.9 RowSet Interface
- 28.10 Java DB/Apache Derby
- 28.11 PreparedStatements
- 28.12 Stored Procedures
- 28.14 Wrap-Up
- 28.15 Web Resources
-
Summary
- Section 28.1 Introduction
- Section 28.2 Relational Databases
- Section 28.4.1 Basic SELECT Query
- Section 28.4.2 WHERE Clause
- Section 28.4.3 ORDER BY Clause
- Section 28.4.4 Merging Data from Multiple Tables: INNER JOIN
- Section 28.4.5 INSERT Statement
- Section 28.4.6 UPDATE Statement
- Section 28.4.7 DELETE Statement
- Section 28.8.1 Connecting to and Querying a Database
- Section 28.8.2 Querying the books Database
- Section 28.9 RowSet Interface
- Section 28.10 Java DB/Apache Derby
- Section 28.11 PreparedStatements
- Section 28.12 Stored Procedures
- Section 28.13 Transaction Processing
- Self-Review Exercise
- Exercises
-
29 JavaServer™ Faces Web Apps: Part 1
- Objectives
- 29.1 Introduction
- 29.2 HyperText Transfer Protocol (HTTP) Transactions
- 29.3 Multitier Application Architecture
-
29.4 Your First JSF Web App
- Executing the WebTime App
- Facelets: XHTML and JSF Markup
- XML Declaration, Comments and the DOCTYPE Declaration
- Specifying the XML Namespaces Used in the Document
- The h:head and h:body Elements
- JavaBeans
- Class WebTimeBean
- The @ManagedBean Annotation
- Processing the EL Expression
- Creating the JSF Web Application Project
- Examining the NetBeans Projects Window
- Examining the Default index.xhtml Page
- Editing the h:head Element’s Contents
- Editing the h:body Element’s Contents
- Defining the Page’s Logic: Class WebTimeBean
- Adding the EL Expression to the index.xhtml Page
- Running the Application
- Debugging the Application
- Testing the Application from Other Web Browsers
- 29.5 Model-View-Controller Architecture of JSF Apps
- 29.6 Common JSF Components
-
29.7 Validation Using JSF Standard Validators
- Validating Form Data in a Web Application
- Class ValidationBean
- index.xhtml
- First Row of the h:panelGrid
- Validating the nameInputText Element’s Contents
- Second and Third Rows of the h:panelGrid
- Validating the e-Mail Address
- Validating the Phone Number
- Submitting the Form—More Details of the JSF Lifecycle
- 29.8 Session Tracking
- 29.9 Wrap-Up
-
Summary
- Section 29.1 Introduction
- Section 29.2 HyperText Transfer Protocol (HTTP) Transactions
- Section 29.3 Multitier Application Architecture
- Section 29.4 Your First JSF Web App
- Section 29.5 Model-View-Controller Architecture of JSF Apps
- Section 29.6 Common JSF Components
- Section 29.7 Validation Using JSF Standard Validators
- Section 29.8 Session Tracking
- Self-Review Exercises
- Exercises
-
30 JavaServer™ Faces Web Apps: Part 2
- Objectives
- Outline
- 30.1 Introduction
- 30.2 Accessing Databases in Web Apps
- 30.3 Ajax
- 30.4 Adding Ajax Functionality to the Validation App
- 30.5 Wrap-Up
- Summary
- Self-Review Exercise
- Exercises
-
31 Web Services
- Objectives
- Outline
- 31.1 Introduction
- 31.2 Web Service Basics
- 31.3 Simple Object Access Protocol (SOAP)
- 31.4 Representational State Transfer (REST)
- 31.5 JavaScript Object Notation (JSON)
-
31.6 Publishing and Consuming SOAP-Based Web Services
- 31.6.1 Creating a Web Application Project and Adding a Web Service Class in NetBeans
- 31.6.2 Defining the WelcomeSOAP Web Service in NetBeans
- 31.6.3 Publishing the WelcomeSOAP Web Service from NetBeans
- 31.6.4 Testing the WelcomeSOAP Web Service with GlassFish Application Server’s Tester Web Page
- 31.6.5 Describing a Web Service with the Web Service Description Language (WSDL)
- 31.6.6 Creating a Client to Consume the WelcomeSOAP Web Service
- 31.6.7 Consuming the WelcomeSOAP Web Service
- 31.7 Publishing and Consuming REST-Based XML Web Services
- 31.8 Publishing and Consuming REST-Based JSON Web Services
- 31.9 Session Tracking in a SOAP Web Service
- 31.10 Consuming a Database-Driven SOAP Web Service
- 31.11 Equation Generator: Returning User-Defined Types
- 31.12 Wrap-Up
-
Summary
- Section 31.1 Introduction
- Section 31.2 Web Service Basics
- Section 31.3 Simple Object Access Protocol (SOAP)
- Section 31.4 Representational State Transfer (REST)
-
Section 31.5 JavaScript Object Notation (JSON)
- Section 31.6.1 Creating a Web Application Project and Adding a Web Service Class in NetBeans
- Section 31.6.2 Defining the WelcomeSOAP Web Service in NetBeans
- Section 31.6.3 Publishing the WelcomeSOAP Web Service from NetBeans
- Section 31.6.4 Testing the WelcomeSOAP Web Service with GlassFish Application Server’s Tester Web Page
- Section 31.6.5 Describing a Web Service with the Web Service Description Language (WSDL)
- Section 31.6.6 Creating a Client to Consume the WelcomeSOAP Web Service
- Section 31.6.7 Consuming the WelcomeSOAP Web Service
- Section 31.7.1 Creating a REST-Based XML Web Service
- Section 31.7.2 Consuming a REST-Based XML Web Service
- Section 31.8 Publishing and Consuming REST-Based JSON Web Services
- Section 31.9 Session Tracking in a SOAP Web Service
- Section 31.11 Equation Generator: Returning User-Defined Types
- Self-Review Exercises
- Exercises
- Making a Difference
- A Operator Precedence Chart
- B ASCII Character Set
- C Keywords and Reserved Words
- D Primitive Types
- E Using the Java API Documentation
- F Using the Debugger
-
G Formatted Output
- Objectives
- Outline
- G.1 Introduction
- G.2 Streams
- G.3 Formatting Output with printf
- G.4 Printing Integers
- G.5 Printing Floating-Point Numbers
- G.6 Printing Strings and Characters
- G.8 Other Conversion Characters
- G.10 Using Flags in the printf Format String
- G.11 Printing with Argument Indices
- G.12 Printing Literals and Escape Sequences
- G.14 Wrap-Up
-
Summary
- Section G.2 Streams
- Section G.3 Formatting Output with printf
- Section G.4 Printing Integers
- Section G.5 Printing Floating-Point Numbers
- Section G.6 Printing Strings and Characters
- Section G.7 Printing Dates and Times
- Section G.8 Other Conversion Characters
- Section G.9 Printing with Field Widths and Precisions
- Section G.10 Using Flags in the printf Format String
- Section G.11 Printing with Argument Indices
- Section G.13 Formatting Output with Class Formatter
- Self-Review Exercises
- Exercises
-
H Number Systems
- Objectives
- H.1 Introduction
- H.2 Abbreviating Binary Numbers as Octal and Hexadecimal Numbers
- H.3 Converting Octal and Hexadecimal Numbers to Binary Numbers
- H.4 Converting from Binary, Octal or Hexadecimal to Decimal
- H.5 Converting from Decimal to Binary, Octal or Hexadecimal
- H.6 Negative Binary Numbers: Two’s Complement Notation
- Summary
- Self-Review Exercises
- Exercises
- I GroupLayout
- J Java Desktop Integration Components
- K Mashups
- L Unicode®
- Appendices on the Web
- Index
Product information
- Title: Java How to Program (early objects), 9/e
- Author(s):
- Release date: February 2011
- Publisher(s): Pearson
- ISBN: 9780132770873
You might also like
book
Java How To Program, Late Objects, 11th Edition
For courses in Java programming Unparalleled breadth and depth of object-oriented programming concepts The Deitels’ groundbreaking …
video
Java Programming Basics
4+ Hours of Video Instruction Overview Learn Java and Object-Oriented Programming concepts and techniques using hands-on …
book
Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17
Learn the fundamentals of the Java 17 LTS or Java Standard Edition version 17 Long Term …
video
Java for beginners: Step-by-step hands-on guide to Java
We are a group of coders and programmers ourselves. So we understand the importance of learning …