Introduction to Java Programming and Data Structures, Global Edition
Höfundur:
Y. Daniel Liang (Útgáfa: 13)
Kaup valmöguleikar
Introduction to Java Programming and Data Structures seamlessly integrates programming, data structures and algorithms into 1 text. It takes a fundamentals-first approach, helping you build a strong foundation of basic programming concepts and techniques before moving on to object-oriented and advanced Java programming. Author Daniel Liang explains programming in an easy-to-follow, problem-driven way that focuses on problem solving rather than syntax.
Nánar um bókina
- Pearson International Content
- 9781292469973
- 9781292737997
- ePub
- 13
- Y. Daniel Liang
- English
- 2025-04-01
- 100
- 2
- 2
Kaflar
- Cover
- Front Matter
- TitlePage
- Copyright
- Dedication
- Preface
- Note to Students
- Note to Instructors
- New Features
- Flexible Chapter Ordering
- Instructor Supplements
- Meet the Author
- Acknowledgments
- Brief Contents
- Contents
- VideoNote Reference Table
- Animations
- 1: Introduction to Computers, Programs, and Java
- 1: Objectives
- 1.1: Introduction
- 1.1: Introduction
- 1.2: What Is a Computer?
- 1.2: What Is a Computer?
- 1.2.1: Central Processing Unit
- 1.2.1: Central Processing Unit
- 1.2.2: Bits and Bytes
- 1.2.2: Bits and Bytes
- 1.2.3: Memory
- 1.2.3: Memory
- 1.2.4: Storage Devices
- 1.2.4: Storage Devices
- 1.2.5: Input and Output Devices
- 1.2.5: Input and Output Devices
- 1.2.6: Communication Devices
- 1.2.6: Communication Devices
- 1.3: Programming Languages
- 1.3: Programming Languages
- 1.4: Operating Systems
- 1.4: Operating Systems
- 1.5: Java, the World Wide Web, and Beyond
- 1.5: Java, the World Wide Web, and Beyond
- 1.6: The Java Language Specification, API, JDK, JRE, and IDE
- 1.6: The Java Language Specification, API, JDK, JRE, and IDE
- 1.7: A Simple Java Program
- 1.7: A Simple Java Program
- 1.8: Creating, Compiling, and Executing a Java Program
- 1.8: Creating, Compiling, and Executing a Java Program
- 1.9: Programming Style and Documentation
- 1.9: Programming Style and Documentation
- 1.10: Programming Errors
- 1.10: Programming Errors
- 1.11: Developing Java Programs Using NetBeans
- 1.11: Developing Java Programs Using NetBeans
- 1.12: Developing Java Programs Using Eclipse
- 1.12: Developing Java Programs Using Eclipse
- Chapter 1: Key Terms
- Chapter 1: Key Terms
- Chapter 1: Summary
- Chapter 1: Summary
- Chapter 1: Programming Challenges
- Chapter 1: Programming Challenges
- 2: Elementary Programming
- 2: Objectives
- 2.1: Introduction
- 2.1: Introduction
- 2.2: Writing a Simple Program
- 2.2: Writing a Simple Program
- 2.3: Reading Input from the Console
- 2.3: Reading Input from the Console
- 2.4: Identifiers
- 2.4: Identifiers
- 2.5: Variables
- 2.5: Variables
- 2.6: Assignment Statements and Assignment Expressions
- 2.6: Assignment Statements and Assignment Expressions
- 2.7: Named Constants
- 2.7: Named Constants
- 2.8: Naming Conventions
- 2.8: Naming Conventions
- 2.9: Numeric Data Types and Operations
- 2.9: Numeric Data Types and Operations
- 2.9.1: Reading Numbers from the Keyboard
- 2.9.1: Reading Numbers from the Keyboard
- 2.9.2: Numeric Operators
- 2.9.2: Numeric Operators
- 2.9.3: Exponent Operations
- 2.9.3: Exponent Operations
- 2.10: Numeric Literals
- 2.10: Numeric Literals
- 2.11: JShell
- 2.11: JShell
- 2.12: Evaluating Expressions and Operator Precedence
- 2.12: Evaluating Expressions and Operator Precedence
- 2.13: Case Study: Displaying the Current Time
- 2.13: Case Study: Displaying the Current Time
- 2.14: Augmented Assignment Operators
- 2.14: Augmented Assignment Operators
- 2.15: Increment and Decrement Operators
- 2.15: Increment and Decrement Operators
- 2.16: Numeric Type Conversions and Casting
- 2.16: Numeric Type Conversions and Casting
- 2.17: Software Development Process
- 2.17: Software Development Process
- 2.18: Case Study: Counting Monetary Units
- 2.18: Case Study: Counting Monetary Units
- 2.19: Common Errors and Pitfalls
- 2.19: Common Errors and Pitfalls
- Chapter 2: Key Terms
- Chapter 2: Key Terms
- Chapter 2: Summary
- Chapter 2: Summary
- Chapter 2: Programming Challenges
- Chapter 2: Programming Challenges
- 3: Selections
- 3: Objectives
- 3.1: Introduction
- 3.1: Introduction
- 3.2: boolean Data Types, Values, and Expressions
- 3.2: boolean Data Types, Values, and Expressions
- 3.3: if Statements
- 3.3: if Statements
- 3.4: Two-Way if-else Statements
- 3.4: Two-Way if-else Statements
- 3.5: Nested if and Multi-Way if-else Statements
- 3.5: Nested if and Multi-Way if-else Statements
- 3.6: Common Errors and Pitfalls
- 3.6: Common Errors and Pitfalls
- 3.7: Generating Random Numbers
- 3.7: Generating Random Numbers
- 3.8: Case Study: Computing Body Mass Index
- 3.8: Case Study: Computing Body Mass Index
- 3.9: Case Study: Computing Taxes
- 3.9: Case Study: Computing Taxes
- 3.10: Logical Operators
- 3.10: Logical Operators
- 3.11: Case Study: Determining Leap Year
- 3.11: Case Study: Determining Leap Year
- 3.12: Case Study: Lottery
- 3.12: Case Study: Lottery
- 3.13: switch Statements and Expressions
- 3.13: switch Statements and Expressions
- 3.14: Conditional Operators
- 3.14: Conditional Operators
- 3.15: Operator Precedence and Associativity
- 3.15: Operator Precedence and Associativity
- 3.16: Debugging
- 3.16: Debugging
- Chapter 3: Key Terms
- Chapter 3: Key Terms
- Chapter 3: Summary
- Chapter 3: Summary
- Chapter 3: Programming Challenges
- Chapter 3: Programming Challenges
- 4: Mathematical Functions, Characters, and Strings
- 4: Objectives
- 4.1: Introduction
- 4.1: Introduction
- 4.2: Common Mathematical Functions
- 4.2: Common Mathematical Functions
- 4.2.1: Trigonometric Methods
- 4.2.1: Trigonometric Methods
- 4.2.2: Exponent Methods
- 4.2.2: Exponent Methods
- 4.2.3: The Rounding Methods
- 4.2.3: The Rounding Methods
- 4.2.4: The min, max, and abs Methods
- 4.2.4: The min, max, and abs Methods
- 4.2.5: The random Method
- 4.2.5: The random Method
- 4.2.6: Case Study: Computing Angles of a Triangle
- 4.2.6: Case Study: Computing Angles of a Triangle
- 4.3: Character Data Type and Operations
- 4.3: Character Data Type and Operations
- 4.3.1: Unicode and ASCII Code
- 4.3.1: Unicode and ASCII Code
- 4.3.2: Escape Sequences for Special Characters
- 4.3.2: Escape Sequences for Special Characters
- 4.3.3: Casting between char and Numeric Types
- 4.3.3: Casting between char and Numeric Types
- 4.3.4: Comparing and Testing Characters
- 4.3.4: Comparing and Testing Characters
- 4.4: The String Type
- 4.4: The String Type
- 4.4.1: Getting String Length
- 4.4.1: Getting String Length
- 4.4.2: Getting Characters from a String
- 4.4.2: Getting Characters from a String
- 4.4.3: Concatenating Strings
- 4.4.3: Concatenating Strings
- 4.4.4: Converting Strings
- 4.4.4: Converting Strings
- 4.4.5: Reading a String from the Console
- 4.4.5: Reading a String from the Console
- 4.4.6: Reading a Character from the Console
- 4.4.6: Reading a Character from the Console
- 4.4.7: Comparing Strings
- 4.4.7: Comparing Strings
- 4.4.8: Obtaining Substrings
- 4.4.8: Obtaining Substrings
- 4.4.9: Finding a Character or a Substring in a String
- 4.4.9: Finding a Character or a Substring in a String
- 4.4.10: Conversion between Strings and Numbers
- 4.4.10: Conversion between Strings and Numbers
- 4.5: Case Studies
- 4.5: Case Studies
- 4.6: Formatting Console Output
- 4.6: Formatting Console Output
- 4.7: Text Blocks
- 4.7: Text Blocks
- Chapter 4: Key Terms
- Chapter 4: Key Terms
- Chapter 4: Summary
- Chapter 4: Summary
- Chapter 4: Programming Challenges
- Chapter 4: Programming Challenges
- 5: Loops
- 5: Objectives
- 5.1: Introduction
- 5.1: Introduction
- 5.2: The while Loop
- 5.2: The while Loop
- 5.3: Case Study: Guessing Numbers
- 5.3: Case Study: Guessing Numbers
- 5.4: Loop Design Strategies
- 5.4: Loop Design Strategies
- 5.5: Controlling Loop with the User Confirmation or a Sentinel Value
- 5.5: Controlling Loop with the User Confirmation or a Sentinel Value
- 5.6: The do-while Loop
- 5.6: The do-while Loop
- 5.7: The for Loop
- 5.7: The for Loop
- 5.8: Which Loop to Use?
- 5.8: Which Loop to Use?
- 5.9: Nested Loops
- 5.9: Nested Loops
- 5.10: Minimizing Numeric Errors
- 5.10: Minimizing Numeric Errors
- 5.11: Case Studies
- 5.11: Case Studies
- 5.12: Keywords Break and Continue
- 5.12: Keywords Break and Continue
- 5.13: Case Study: Checking Palindromes
- 5.13: Case Study: Checking Palindromes
- 5.14: Case Study: Displaying Prime Numbers
- 5.14: Case Study: Displaying Prime Numbers
- Chapter 5: Key Terms
- Chapter 5: Key Terms
- Chapter 5: Summary
- Chapter 5: Summary
- Chapter 5: Programming Challenges
- Chapter 5: Programming Challenges
- 6: Methods
- 6: Objectives
- 6.1: Introduction
- 6.1: Introduction
- 6.2: Defining a Method
- 6.2: Defining a Method
- 6.3: Calling a Method
- 6.3: Calling a Method
- 6.4: Void Methods vs. Value-Returning Methods
- 6.4: Void Methods vs. Value-Returning Methods
- 6.5: Passing Arguments by Values
- 6.5: Passing Arguments by Values
- 6.6: Modularizing Code
- 6.6: Modularizing Code
- 6.7: Case Study: Converting Hexadecimals to Decimals
- 6.7: Case Study: Converting Hexadecimals to Decimals
- 6.8: Overloading Methods
- 6.8: Overloading Methods
- 6.9: The Scope of Variables
- 6.9: The Scope of Variables
- 6.10: Case Study: Generating Random Characters
- 6.10: Case Study: Generating Random Characters
- 6.11: Method Abstraction and Stepwise Refinement
- 6.11: Method Abstraction and Stepwise Refinement
- Chapter 6: Key Terms
- Chapter 6: Key Terms
- Chapter 6: Summary
- Chapter 6: Summary
- Chapter 6: Programming Challenges
- Chapter 6: Programming Challenges
- 7: Single-Dimensional Arrays
- 7: Objectives
- 7.1: Introduction
- 7.1: Introduction
- 7.2: Array Basics
- 7.2: Array Basics
- 7.2.1: Declaring Array Variables
- 7.2.1: Declaring Array Variables
- 7.2.2: Creating Arrays
- 7.2.2: Creating Arrays
- 7.2.3: Array Size and Default Values
- 7.2.3: Array Size and Default Values
- 7.2.4: Accessing Array Elements
- 7.2.4: Accessing Array Elements
- 7.2.5: Array Initializers
- 7.2.5: Array Initializers
- 7.2.6: Processing Arrays
- 7.2.6: Processing Arrays
- 7.2.7: Foreach Loops
- 7.2.7: Foreach Loops
- 7.3: Case Study: Analyzing Numbers
- 7.3: Case Study: Analyzing Numbers
- 7.4: Case Study: Deck of Cards
- 7.4: Case Study: Deck of Cards
- 7.5: Copying Arrays
- 7.5: Copying Arrays
- 7.6: Passing Arrays to Methods
- 7.6: Passing Arrays to Methods
- 7.7: Returning an Array from a Method
- 7.7: Returning an Array from a Method
- 7.8: Case Study: Counting the Occurrences of Each Letter
- 7.8: Case Study: Counting the Occurrences of Each Letter
- 7.9: Variable-Length Argument Lists
- 7.9: Variable-Length Argument Lists
- 7.10: Searching Arrays
- 7.10: Searching Arrays
- 7.11: Sorting Arrays
- 7.11: Sorting Arrays
- 7.12: The Arrays Class
- 7.12: The Arrays Class
- 7.13: Command-Line Arguments
- 7.13: Command-Line Arguments
- Chapter 7: Key Terms
- Chapter 7: Key Terms
- Chapter 7: Summary
- Chapter 7: Summary
- Chapter 7: Programming Challenges
- Chapter 7: Programming Challenges
- 8: Multidimensional Arrays
- 8: Objectives
- 8.1: Introduction
- 8.1: Introduction
- 8.2: Two-Dimensional Array Basics
- 8.2: Two-Dimensional Array Basics
- 8.2.1: Declaring Variables of Two-Dimensional Arrays and Creating Two-Dimensional Arrays
- 8.2.1: Declaring Variables of Two-Dimensional Arrays and Creating Two-Dimensional Arrays
- 8.2.2: Obtaining the Lengths of Two-Dimensional Arrays
- 8.2.2: Obtaining the Lengths of Two-Dimensional Arrays
- 8.2.3: Ragged Arrays
- 8.2.3: Ragged Arrays
- 8.3: Processing Two-Dimensional Arrays
- 8.3: Processing Two-Dimensional Arrays
- 8.4: Passing Two-Dimensional Arrays to Methods
- 8.4: Passing Two-Dimensional Arrays to Methods
- 8.5: Case Study: Grading a Multiple-Choice Test
- 8.5: Case Study: Grading a Multiple-Choice Test
- 8.6: Case Study: Finding the Closest Pair
- 8.6: Case Study: Finding the Closest Pair
- 8.7: Case Study: Sudoku
- 8.7: Case Study: Sudoku
- 8.8: Multidimensional Arrays
- 8.8: Multidimensional Arrays
- Chapter 8: Key Terms
- Chapter 8: Key Terms
- Chapter 8: Summary
- Chapter 8: Summary
- Chapter 8: Programming Challenges
- Chapter 8: Programming Challenges
- 9: Objects and Classes
- 9: Objectives
- 9.1: Introduction
- 9.1: Introduction
- 9.2: Defining Classes for Objects
- 9.2: Defining Classes for Objects
- 9.3: Example: Defining Classes and Creating Objects
- 9.3: Example: Defining Classes and Creating Objects
- 9.4: Constructing Objects Using Constructors
- 9.4: Constructing Objects Using Constructors
- 9.5: Accessing Objects via Reference Variables
- 9.5: Accessing Objects via Reference Variables
- 9.5.1: Accessing an Object’s Data and Methods
- 9.5.1: Accessing an Object’s Data and Methods
- 9.5.2: Reference Data Fields and the Null Value
- 9.5.2: Reference Data Fields and the Null Value
- 9.5.3: Differences between Variables of Primitive Types and Reference Types
- 9.5.3: Differences between Variables of Primitive Types and Reference Types
- 9.6: Using Classes from the Java Library
- 9.6: Using Classes from the Java Library
- 9.7: Static Variables, Constants, and Methods
- 9.7: Static Variables, Constants, and Methods
- 9.8: Visibility Modifiers
- 9.8: Visibility Modifiers
- 9.9: Data Field Encapsulation
- 9.9: Data Field Encapsulation
- 9.10: Passing Objects to Methods
- 9.10: Passing Objects to Methods
- 9.11: Array of Objects
- 9.11: Array of Objects
- 9.12: Immutable Objects and Classes
- 9.12: Immutable Objects and Classes
- 9.13: The Scope of Variables
- 9.13: The Scope of Variables
- 9.14: The this Reference
- 9.14: The this Reference
- 9.14.1: Using this to Reference Data Fields
- 9.14.1: Using this to Reference Data Fields
- 9.14.2: Using this to Invoke a Constructor
- 9.14.2: Using this to Invoke a Constructor
- Chapter 9: Key Terms
- Chapter 9: Key Terms
- Chapter 9: Summary
- Chapter 9: Summary
- Chapter 9: Programming Challenges
- Chapter 9: Programming Challenges
- 10: Object-Oriented Thinking
- 10: Objectives
- 10.1: Introduction
- 10.1: Introduction
- 10.2: Class Abstraction and Encapsulation
- 10.2: Class Abstraction and Encapsulation
- 10.3: Thinking in Objects
- 10.3: Thinking in Objects
- 10.4: Class Relationships
- 10.4: Class Relationships
- 10.5: Case Study: Designing the Course Class
- 10.5: Case Study: Designing the Course Class
- 10.6: Case Study: Designing a Class for Stacks
- 10.6: Case Study: Designing a Class for Stacks
- 10.7: Processing Primitive Data Type Values as Objects
- 10.7: Processing Primitive Data Type Values as Objects
- 10.8: Automatic Conversion between Primitive Types and Wrapper Class Types
- 10.8: Automatic Conversion between Primitive Types and Wrapper Class Types
- 10.9: The BigInteger and BigDecimal Classes
- 10.9: The BigInteger and BigDecimal Classes
- 10.10: The String Class
- 10.10: The String Class
- 10.10.1: Immutable Strings and Interned Strings
- 10.10.1: Immutable Strings and Interned Strings
- 10.10.2: Replacing and Splitting Strings
- 10.10.2: Replacing and Splitting Strings
- 10.10.3: Matching, Replacing, and Splitting by Patterns
- 10.10.3: Matching, Replacing, and Splitting by Patterns
- 10.10.4: Conversion between Strings and Arrays
- 10.10.4: Conversion between Strings and Arrays
- 10.10.5: Converting Characters and Numeric Values to Strings
- 10.10.5: Converting Characters and Numeric Values to Strings
- 10.10.6: Formatting Strings
- 10.10.6: Formatting Strings
- 10.11: The StringBuilder and StringBuffer Classes
- 10.11: The StringBuilder and StringBuffer Classes
- 10.11.1 Modifying Strings in the StringBuilder
- 10.11.1 Modifying Strings in the StringBuilder
- 10.11.2 The toString, capacity, length, setLength, and charAt Methods
- 10.11.2 The toString, capacity, length, setLength, and charAt Methods
- 10.11.3: Case Study: Ignoring Nonalphanumeric Characters When Checking Palindromes
- 10.11.3: Case Study: Ignoring Nonalphanumeric Characters When Checking Palindromes
- Chapter 10: Key Terms
- Chapter 10: Key Terms
- Chapter 10: Summary
- Chapter 10: Summary
- Chapter 10: Programming Challenges
- Chapter 10: Programming Challenges
- 11: Inheritance and Polymorphism
- 11: Objectives
- 11.1: Introduction
- 11.1: Introduction
- 11.2: Superclasses and Subclasses
- 11.2: Superclasses and Subclasses
- 11.3: Using the Super Keyword
- 11.3: Using the Super Keyword
- 11.3.1: Calling Superclass Constructors
- 11.3.1: Calling Superclass Constructors
- 11.3.2: Constructor Chaining
- 11.3.2: Constructor Chaining
- 11.3.3: Calling Superclass Methods
- 11.3.3: Calling Superclass Methods
- 11.4: Overriding Methods
- 11.4: Overriding Methods
- 11.5: Overriding vs. Overloading
- 11.5: Overriding vs. Overloading
- 11.6: The Object Class and Its toString() Method
- 11.6: The Object Class and Its toString() Method
- 11.7: Polymorphism
- 11.7: Polymorphism
- 11.8: Dynamic Binding
- 11.8: Dynamic Binding
- 11.9: Casting Objects and the instanceof Operator
- 11.9: Casting Objects and the instanceof Operator
- 11.10: The Object’s equals Method
- 11.10: The Object’s equals Method
- 11.11: The ArrayList Class
- 11.11: The ArrayList Class
- 11.11.1: ArrayList vs. Array
- 11.11.1: ArrayList vs. Array
- 11.12: Useful Methods for Lists
- 11.12: Useful Methods for Lists
- 11.13: Case Study: A Custom Stack Class
- 11.13: Case Study: A Custom Stack Class
- 11.14: The protected Data and Methods
- 11.14: The protected Data and Methods
- 11.15: Preventing Extending and Overriding
- 11.15: Preventing Extending and Overriding
- 11.16: Lombok: Generating Boilerplate Code Using Annotations
- 11.16: Lombok: Generating Boilerplate Code Using Annotations
- Chapter 11: Key Terms
- Chapter 11: Key Terms
- Chapter 11: Summary
- Chapter 11: Summary
- Chapter 11: Programming Challenges
- Chapter 11: Programming Challenges
- 12: Exception Handling and Text I/O
- 12: Objectives
- 12.1: Introduction
- 12.1: Introduction
- 12.2: Exception-Handling Overview
- 12.2: Exception-Handling Overview
- 12.3: Exception Types
- 12.3: Exception Types
- 12.4: Declaring, Throwing, and Catching Exceptions
- 12.4: Declaring, Throwing, and Catching Exceptions
- 12.4.1: Declaring Exceptions
- 12.4.1: Declaring Exceptions
- 12.4.2: Throwing Exceptions
- 12.4.2: Throwing Exceptions
- 12.4.3: Catching Exceptions
- 12.4.3: Catching Exceptions
- 12.4.4: Getting Information from Exceptions
- 12.4.4: Getting Information from Exceptions
- 12.4.5: Example: Declaring, Throwing, and Catching Exceptions
- 12.4.5: Example: Declaring, Throwing, and Catching Exceptions
- 12.5: The finally Clause
- 12.5: The finally Clause
- 12.6: When to Use Exceptions
- 12.6: When to Use Exceptions
- 12.7: Rethrowing Exceptions
- 12.7: Rethrowing Exceptions
- 12.8: Chained Exceptions
- 12.8: Chained Exceptions
- 12.9: Defining Custom Exception Classes
- 12.9: Defining Custom Exception Classes
- 12.10: The File Class
- 12.10: The File Class
- 12.11: File Input and Output
- 12.11: File Input and Output
- 12.11.1: Writing Data Using PrintWriter
- 12.11.1: Writing Data Using PrintWriter
- 12.11.2: Closing Resources Automatically Using try-with-resources
- 12.11.2: Closing Resources Automatically Using try-with-resources
- 12.11.3: Reading Data Using Scanner
- 12.11.3: Reading Data Using Scanner
- 12.11.4: How Does Scanner Work?
- 12.11.4: How Does Scanner Work?
- 12.11.5: Case Study: Replacing Text
- 12.11.5: Case Study: Replacing Text
- 12.12: Reading Data from the Web
- 12.12: Reading Data from the Web
- 12.13: Case Study: Web Crawler
- 12.13: Case Study: Web Crawler
- Chapter 12: Key Terms
- Chapter 12: Key Terms
- Chapter 12: Summary
- Chapter 12: Summary
- Chapter 12: Programming Challenges
- Chapter 12: Programming Challenges
- 13: Abstract Classes and Interfaces
- 13: Objectives
- 13.1: Introduction
- 13.1: Introduction
- 13.2: Abstract Classes
- 13.2: Abstract Classes
- 13.2.1: Why Abstract Methods?
- 13.2.1: Why Abstract Methods?
- 13.2.2: Interesting Points about Abstract Classes
- 13.2.2: Interesting Points about Abstract Classes
- 13.3: Case Study: the Abstract Number Class
- 13.3: Case Study: the Abstract Number Class
- 13.4: Case Study: Calendar and GregorianCalendar
- 13.4: Case Study: Calendar and GregorianCalendar
- 13.5: Interfaces
- 13.5: Interfaces
- 13.6: The Comparable Interface
- 13.6: The Comparable Interface
- 13.7: The Cloneable Interface
- 13.7: The Cloneable Interface
- 13.8: Interfaces vs. Abstract Classes
- 13.8: Interfaces vs. Abstract Classes
- 13.9: Case Study: The Rational Class
- 13.9: Case Study: The Rational Class
- 13.10: Class Design Guidelines
- 13.10: Class Design Guidelines
- 13.11: Records
- 13.11: Records
- Chapter 13: Key Terms
- Chapter 13: Key Terms
- Chapter 13: Summary
- Chapter 13: Summary
- Chapter 13: Programming Challenges
- Chapter 13: Programming Challenges
- 14: JavaFX Basics
- 14: Objectives
- 14.1: Introduction
- 14.1: Introduction
- 14.2: JavaFX vs Swing and AWT
- 14.2: JavaFX vs Swing and AWT
- 14.3: The Basic Structure of a JavaFX Program
- 14.3: The Basic Structure of a JavaFX Program
- 14.4: Panes, Groups, UI Controls, and Shapes
- 14.4: Panes, Groups, UI Controls, and Shapes
- 14.5: Property Binding
- 14.5: Property Binding
- 14.6: Common Properties and Methods for Nodes
- 14.6: Common Properties and Methods for Nodes
- 14.7: The Color Class
- 14.7: The Color Class
- 14.8: The Font Class
- 14.8: The Font Class
- 14.9: The Image and ImageView Classes
- 14.9: The Image and ImageView Classes
- 14.10: Layout Panes and Groups
- 14.10: Layout Panes and Groups
- 14.10.1: FlowPane
- 14.10.1: FlowPane
- 14.10.2: GridPane
- 14.10.2: GridPane
- 14.10.3: BorderPane
- 14.10.3: BorderPane
- 14.10.4: HBox and VBox
- 14.10.4: HBox and VBox
- 14.11: Shapes
- 14.11: Shapes
- 14.11.1: Text
- 14.11.1: Text
- 14.11.2: Line
- 14.11.2: Line
- 14.11.3: Rectangle
- 14.11.3: Rectangle
- 14.11.4: Circle and Ellipse
- 14.11.4: Circle and Ellipse
- 14.11.5: Arc
- 14.11.5: Arc
- 14.11.6: Polygon and Polyline
- 14.11.6: Polygon and Polyline
- 14.12: Case Study: The ClockPane Class
- 14.12: Case Study: The ClockPane Class
- Chapter 14: Key Terms
- Chapter 14: Key Terms
- Chapter 14: Summary
- Chapter 14: Summary
- Chapter 14: Programming Challenges
- Chapter 14: Programming Challenges
- 15: Event-Driven Programming and Animations
- 15: Objectives
- 15.1: Introduction
- 15.1: Introduction
- 15.2: Events and Event Sources
- 15.2: Events and Event Sources
- 15.3: Registering Handlers and Handling Events
- 15.3: Registering Handlers and Handling Events
- 15.4: Inner Classes
- 15.4: Inner Classes
- 15.5: Anonymous Inner Class Handlers
- 15.5: Anonymous Inner Class Handlers
- 15.6: Simplifying Event Handling Using Lambda Expressions
- 15.6: Simplifying Event Handling Using Lambda Expressions
- 15.7: Case Study: Loan Calculator
- 15.7: Case Study: Loan Calculator
- 15.8: Mouse Events
- 15.8: Mouse Events
- 15.9: Key Events
- 15.9: Key Events
- 15.10: Listeners for Observable Objects
- 15.10: Listeners for Observable Objects
- 15.11: Animation
- 15.11: Animation
- 15.11.1: PathTransition
- 15.11.1: PathTransition
- 15.11.2: FadeTransition
- 15.11.2: FadeTransition
- 15.11.3: Timeline
- 15.11.3: Timeline
- 15.12: Case Study: Bouncing Ball
- 15.12: Case Study: Bouncing Ball
- 15.13: Case Study: US Map
- 15.13: Case Study: US Map
- Chapter 15: Key Terms
- Chapter 15: Key Terms
- Chapter 15: Summary
- Chapter 15: Summary
- Chapter 15: Programming Challenges
- Chapter 15: Programming Challenges
- 16: JavaFX UI Controls and Multimedia
- 16: Objectives
- 16.1: Introduction
- 16.1: Introduction
- 16.2: Labeled and Label
- 16.2: Labeled and Label
- 16.3: Button
- 16.3: Button
- 16.4: CheckBox
- 16.4: CheckBox
- 16.5: RadioButton
- 16.5: RadioButton
- 16.6: TextField
- 16.6: TextField
- 16.7: TextArea
- 16.7: TextArea
- 16.8: ComboBox
- 16.8: ComboBox
- 16.9: ListView
- 16.9: ListView
- 16.10: ScrollBar
- 16.10: ScrollBar
- 16.11: Slider
- 16.11: Slider
- 16.12: Case Study: Developing a Tic-Tac-Toe Game
- 16.12: Case Study: Developing a Tic-Tac-Toe Game
- 16.13: Video and Audio
- 16.13: Video and Audio
- 16.14: Case Study: National Flags and Anthems
- 16.14: Case Study: National Flags and Anthems
- Chapter 16: Summary
- Chapter 16: Summary
- Chapter 16: Programming Challenges
- Chapter 16: Programming Challenges
- 17: Binary I/O
- 17: Objectives
- 17.1: Introduction
- 17.1: Introduction
- 17.2: How Is Text I/O Handled in Java?
- 17.2: How Is Text I/O Handled in Java?
- 17.3: Text I/O vs. Binary I/O
- 17.3: Text I/O vs. Binary I/O
- 17.4: Binary I/O Classes
- 17.4: Binary I/O Classes
- 17.4.1: FileInputStream/FileOutputStream
- 17.4.1: FileInputStream/FileOutputStream
- 17.4.2: FilterInputStream/FilterOutputStream
- 17.4.2: FilterInputStream/FilterOutputStream
- 17.4.3: DataInputStream/DataOutputStream
- 17.4.3: DataInputStream/DataOutputStream
- 17.4.4: BufferedInputStream/BufferedOutputStream
- 17.4.4: BufferedInputStream/BufferedOutputStream
- 17.5: Case Study: Copying Files
- 17.5: Case Study: Copying Files
- 17.6: Object I/O
- 17.6: Object I/O
- 17.6.1: The Serializable Interface
- 17.6.1: The Serializable Interface
- 17.6.2: Serializing Arrays
- 17.6.2: Serializing Arrays
- 17.7: Random-Access Files
- 17.7: Random-Access Files
- Chapter 17: Key Terms
- Chapter 17: Key Terms
- Chapter 17: Summary
- Chapter 17: Summary
- Chapter 17: Programming Challenges
- Chapter 17: Programming Challenges
- 18: Recursion
- 18: Objectives
- 18.1: Introduction
- 18.1: Introduction
- 18.2: Case Study: Computing Factorials
- 18.2: Case Study: Computing Factorials
- 18.3: Case Study: Computing Fibonacci Numbers
- 18.3: Case Study: Computing Fibonacci Numbers
- 18.4: Problem Solving Using Recursion
- 18.4: Problem Solving Using Recursion
- 18.5: Recursive Helper Methods
- 18.5: Recursive Helper Methods
- 18.6: Case Study: Finding the Directory Size
- 18.6: Case Study: Finding the Directory Size
- 18.7: Case Study: Tower of Hanoi
- 18.7: Case Study: Tower of Hanoi
- 18.8: Case Study: Fractals
- 18.8: Case Study: Fractals
- 18.9: Recursion vs. Iteration
- 18.9: Recursion vs. Iteration
- 18.10: Tail Recursion
- 18.10: Tail Recursion
- Chapter 18: Key Terms
- Chapter 18: Key Terms
- Chapter 18: Summary
- Chapter 18: Summary
- Chapter 18: Programming Challenges
- Chapter 18: Programming Challenges
- 19: Generics
- 19: Objectives
- 19.1: Introduction
- 19.1: Introduction
- 19.2: Motivations and Benefits
- 19.2: Motivations and Benefits
- 19.3: Defining Generic Classes and Interfaces
- 19.3: Defining Generic Classes and Interfaces
- 19.4: Generic Methods
- 19.4: Generic Methods
- 19.5: Case Study: Sorting an Array of Objects
- 19.5: Case Study: Sorting an Array of Objects
- 19.6: Raw Types and Backward Compatibility
- 19.6: Raw Types and Backward Compatibility
- 19.7: Wildcard Generic Types
- 19.7: Wildcard Generic Types
- 19.8: Erasure and Restrictions on Generics
- 19.8: Erasure and Restrictions on Generics
- 19.9: Case Study: Generic Matrix Class
- 19.9: Case Study: Generic Matrix Class
- Chapter 19: Key Terms
- Chapter 19: Key Terms
- Chapter 19: Summary
- Chapter 19: Summary
- Chapter 19: Programming Challenges
- Chapter 19: Programming Challenges
- 20: Lists, Stacks, Queues, and Priority Queues
- 20: Objectives
- 20.1: Introduction
- 20.1: Introduction
- 20.2: Collections
- 20.2: Collections
- 20.3: Iterators
- 20.3: Iterators
- 20.4: Using the forEach Method
- 20.4: Using the forEach Method
- 20.5: Lists
- 20.5: Lists
- 20.6: The Comparator Interface
- 20.6: The Comparator Interface
- 20.7: Static Methods for Lists and Collections
- 20.7: Static Methods for Lists and Collections
- 20.8: Case Study: Bouncing Balls
- 20.8: Case Study: Bouncing Balls
- 20.9: Vector and Stack Classes
- 20.9: Vector and Stack Classes
- 20.10: Queues and Priority Queues
- 20.10: Queues and Priority Queues
- 20.11: Case Study: Evaluating Expressions
- 20.11: Case Study: Evaluating Expressions
- Chapter 20: Key Terms
- Chapter 20: Key Terms
- Chapter 20: Summary
- Chapter 20: Summary
- Chapter 20: Programming Challenges
- Chapter 20: Programming Challenges
- 21: Sets and Maps
- 21: Objectives
- 21.1: Introduction
- 21.1: Introduction
- 21.2: Sets
- 21.2: Sets
- 21.2.1: HashSet
- 21.2.1: HashSet
- 21.2.2: LinkedHashSet
- 21.2.2: LinkedHashSet
- 21.2.3: TreeSet
- 21.2.3: TreeSet
- 21.3: Comparing the Performance of Sets and Lists
- 21.3: Comparing the Performance of Sets and Lists
- 21.4: Case Study: Counting Keywords
- 21.4: Case Study: Counting Keywords
- 21.5: Maps
- 21.5: Maps
- 21.6: Case Study: Occurrences of Words
- 21.6: Case Study: Occurrences of Words
- 21.7: Singleton and Unmodifiable Collections and Maps
- 21.7: Singleton and Unmodifiable Collections and Maps
- Chapter 21: Key Terms
- Chapter 21: Key Terms
- Chapter 21: Summary
- Chapter 21: Summary
- Chapter 21: Programming Challenges
- Chapter 21: Programming Challenges
- 22: Developing Efficient Algorithms
- 22: Objectives
- 22.1: Introduction
- 22.1: Introduction
- 22.2: Measuring Algorithm Efficiency Using Big O Notation
- 22.2: Measuring Algorithm Efficiency Using Big O Notation
- 22.3: Examples: Determining Big O
- 22.3: Examples: Determining Big O
- 22.4: Analyzing Algorithm Time Complexity
- 22.4: Analyzing Algorithm Time Complexity
- 22.5: Finding Fibonacci Numbers Using Dynamic Programming
- 22.5: Finding Fibonacci Numbers Using Dynamic Programming
- 22.6: Finding Greatest Common Divisors Using Euclid’s Algorithm
- 22.6: Finding Greatest Common Divisors Using Euclid’s Algorithm
- 22.7: Efficient Algorithms for Finding Prime Numbers
- 22.7: Efficient Algorithms for Finding Prime Numbers
- 22.8: Finding the Closest Pair of Points Using Divide-and-Conquer
- 22.8: Finding the Closest Pair of Points Using Divide-and-Conquer
- 22.9: Solving the Eight Queens Problem Using Backtracking
- 22.9: Solving the Eight Queens Problem Using Backtracking
- 22.10: Computational Geometry: Finding a Convex Hull
- 22.10: Computational Geometry: Finding a Convex Hull
- 22.10.1 Gift-Wrapping Algorithm
- 22.10.1 Gift-Wrapping Algorithm
- 22.10.2 Graham's Algorithm
- 22.10.2 Graham's Algorithm
- 22.11: String Matching
- 22.11: String Matching
- 22.11.1: The Boyer-Moore Algorithm
- 22.11.1: The Boyer-Moore Algorithm
- 22.11.2: The Knuth-Morris-Pratt Algorithm
- 22.11.2: The Knuth-Morris-Pratt Algorithm
- Chapter 22: Key Terms
- Chapter 22: Key Terms
- Chapter 22: Summary
- Chapter 22: Summary
- Chapter 22: Programming Challenges
- Chapter 22: Programming Challenges
- 23: Sorting
- 23: Objectives
- 23.1: Introduction
- 23.1: Introduction
- 23.2: Insertion Sort
- 23.2: Insertion Sort
- 23.3: Bubble Sort
- 23.3: Bubble Sort
- 23.4: Merge Sort
- 23.4: Merge Sort
- 23.5: Quick Sort
- 23.5: Quick Sort
- 23.6: Heap Sort
- 23.6: Heap Sort
- 23.6.1: Storing a Heap
- 23.6.1: Storing a Heap
- 23.6.2: Adding a New Node
- 23.6.2: Adding a New Node
- 23.6.3: Removing the Root
- 23.6.3: Removing the Root
- 23.6.4: The Heap Class
- 23.6.4: The Heap Class
- 23.6.5: Sorting Using the Heap Class
- 23.6.5: Sorting Using the Heap Class
- 23.6.6: Heap Sort Time Complexity
- 23.6.6: Heap Sort Time Complexity
- 23.7: Bucket Sort and Radix Sort
- 23.7: Bucket Sort and Radix Sort
- 23.8: External Sort
- 23.8: External Sort
- Chapter 23: Key Terms
- Chapter 23: Key Terms
- Chapter 23: Summary
- Chapter 23: Summary
- Chapter 23: Programming Challenges
- Chapter 23: Programming Challenges
- 24: Implementing Lists, Stacks, Queues, and Priority Queues
- 24: Objectives
- 24.1: Introduction
- 24.1: Introduction
- 24.2: Common Operations for Lists
- 24.2: Common Operations for Lists
- 24.3: Array Lists
- 24.3: Array Lists
- 24.4: Linked Lists
- 24.4: Linked Lists
- 24.5: The MyLinkedList Class
- 24.5: The MyLinkedList Class
- 24.6: Implementing MyLinkedList
- 24.6: Implementing MyLinkedList
- 24.6.1: Implementing addFirst(e)
- 24.6.1: Implementing addFirst(e)
- 24.6.2: Implementing addLast(T element)
- 24.6.2: Implementing addLast(T element)
- 24.6.3: Implementing add(int index, T element)
- 24.6.3: Implementing add(int index, T element)
- 24.6.4: Implementing removeFirst()
- 24.6.4: Implementing removeFirst()
- 24.6.5: Implementing removeLast()
- 24.6.5: Implementing removeLast()
- 24.6.6: Implementing remove(int index)
- 24.6.6: Implementing remove(int index)
- 24.6.7: The Source Code for LinkedList
- 24.6.7: The Source Code for LinkedList
- 24.7: MyArrayList vs. MyLinkedList
- 24.7: MyArrayList vs. MyLinkedList
- 24.8: Variations of Linked Lists
- 24.8: Variations of Linked Lists
- 24.9: Stacks and Queues
- 24.9: Stacks and Queues
- 24.10: Priority Queues
- 24.10: Priority Queues
- Chapter 24: Summary
- Chapter 24: Summary
- Chapter 24: Programming Challenges
- Chapter 24: Programming Challenges
- 25: Binary Search Trees
- 25: Objectives
- 25.1: Introduction
- 25.1: Introduction
- 25.2: Binary Search Trees Basics
- 25.2: Binary Search Trees Basics
- 25.3: Representing Binary Search Trees
- 25.3: Representing Binary Search Trees
- 25.4: Searching for an Element in BST
- 25.4: Searching for an Element in BST
- 25.5: Inserting an Element into a BST
- 25.5: Inserting an Element into a BST
- 25.6: Tree Traversal
- 25.6: Tree Traversal
- 25.7: The BST Class
- 25.7: The BST Class
- 25.8: Deleting Elements from a BST
- 25.8: Deleting Elements from a BST
- 25.9: Tree Visualization and MVC
- 25.9: Tree Visualization and MVC
- 25.10: Iterators
- 25.10: Iterators
- 25.11: Case Study: Data Compression
- 25.11: Case Study: Data Compression
- Chapter 25: Key Terms
- Chapter 25: Key Terms
- Chapter 25: Summary
- Chapter 25: Summary
- Chapter 25: Programming Challenges
- Chapter 25: Programming Challenges
- 26: AVL Trees
- 26: Objectives
- 26.1: Introduction
- 26.1: Introduction
- 26.2: Rebalancing Trees
- 26.2: Rebalancing Trees
- 26.3: Designing Classes for AVL Trees
- 26.3: Designing Classes for AVL Trees
- 26.4: Overriding the insert Method
- 26.4: Overriding the insert Method
- 26.5: Implementing Rotations
- 26.5: Implementing Rotations
- 26.6: Implementing the delete Method
- 26.6: Implementing the delete Method
- 26.7: The AVLTree Class
- 26.7: The AVLTree Class
- 26.8: Testing the AVLTree Class
- 26.8: Testing the AVLTree Class
- 26.9: AVL Tree Time Complexity Analysis
- 26.9: AVL Tree Time Complexity Analysis
- Chapter 26: Key Terms
- Chapter 26: Key Terms
- Chapter 26: Summary
- Chapter 26: Summary
- Chapter 26: Programming Challenges
- Chapter 26: Programming Challenges
- 27: Hashing
- 27: Objectives
- 27.1: Introduction
- 27.1: Introduction
- 27.2: What Is Hashing?
- 27.2: What Is Hashing?
- 27.3: Hash Functions and Hash Codes
- 27.3: Hash Functions and Hash Codes
- 27.3.1: Hash Codes for Primitive Types
- 27.3.1: Hash Codes for Primitive Types
- 27.3.2: Hash Codes for Strings
- 27.3.2: Hash Codes for Strings
- 27.3.3: Compressing Hash Codes
- 27.3.3: Compressing Hash Codes
- 27.4: Handling Collisions Using Open Addressing
- 27.4: Handling Collisions Using Open Addressing
- 27.5: Handling Collisions Using Separate Chaining
- 27.5: Handling Collisions Using Separate Chaining
- 27.6: Load Factor and Rehashing
- 27.6: Load Factor and Rehashing
- 27.7: Implementing a Map Using Hashing
- 27.7: Implementing a Map Using Hashing
- 27.8: Implementing Set Using Hashing
- 27.8: Implementing Set Using Hashing
- Chapter 27: Key Terms
- Chapter 27: Key Terms
- Chapter 27: Summary
- Chapter 27: Summary
- Chapter 27: Programming Challenges
- Chapter 27: Programming Challenges
- 28: Graphs and Applications
- 28: Objectives
- 28.1: Introduction
- 28.1: Introduction
- 28.2: Basic Graph Terminologies
- 28.2: Basic Graph Terminologies
- 28.3: Representing Graphs
- 28.3: Representing Graphs
- 28.4: Modeling Graphs
- 28.4: Modeling Graphs
- 28.5: Graph Visualization
- 28.5: Graph Visualization
- 28.6: Graph Traversals
- 28.6: Graph Traversals
- 28.7: Depth-First Search (DFS)
- 28.7: Depth-First Search (DFS)
- 28.8: Case Study: The Connected Circles Problem
- 28.8: Case Study: The Connected Circles Problem
- 28.9: Breadth-First Search (BFS)
- 28.9: Breadth-First Search (BFS)
- 28.10: Case Study: The Nine Tails Problem
- 28.10: Case Study: The Nine Tails Problem
- Chapter 28: Key Terms
- Chapter 28: Key Terms
- Chapter 28: Summary
- Chapter 28: Summary
- Chapter 28: Programming Challenges
- Chapter 28: Programming Challenges
- 29: Weighted Graphs and Applications
- 29: Objectives
- 29.1: Introduction
- 29.1: Introduction
- 29.2: Representing Weighted Graphs
- 29.2: Representing Weighted Graphs
- 29.3: The WeightedGraph Class
- 29.3: The WeightedGraph Class
- 29.4: Minimum Spanning Trees
- 29.4: Minimum Spanning Trees
- 29.5: Finding Shortest Paths
- 29.5: Finding Shortest Paths
- 29.6: Case Study: The Weighted Nine Tails Problem
- 29.6: Case Study: The Weighted Nine Tails Problem
- Chapter 29: Key Terms
- Chapter 29: Key Terms
- Chapter 29: Summary
- Chapter 29: Summary
- Chapter 29: Programming Challenges
- Chapter 29: Programming Challenges
- 30: Aggregate Operations for Collection Streams
- 30: Objectives
- 30.1: Introduction
- 30.1: Introduction
- 30.2: Stream Pipelines
- 30.2: Stream Pipelines
- 30.3: IntStream, LongStream, and DoubleStream
- 30.3: IntStream, LongStream, and DoubleStream
- 30.4: Parallel Streams
- 30.4: Parallel Streams
- 30.5: Stream Reduction Using the reduce Method
- 30.5: Stream Reduction Using the reduce Method
- 30.6: Stream Reduction Using the collect Method
- 30.6: Stream Reduction Using the collect Method
- 30.7: Grouping Elements Using the groupingby Collector
- 30.7: Grouping Elements Using the groupingby Collector
- 30.8: Case Studies
- 30.8: Case Studies
- Chapter 30: Key Terms
- Chapter 30: Key Terms
- Chapter 30: Summary
- Chapter 30: Summary
- Chapter 30: Programming Challenges
- Chapter 30: Programming Challenges
- Appendix A: Java Keywords
- Appendix A: Java Keywords
- Appendix B: The ASCII Character Set
- Appendix B: The ASCII Character Set
- Appendix C: Operator Precedence Chart
- Appendix C: Operator Precedence Chart
- Appendix D: Java Modifiers
- Appendix D: Java Modifiers
- Appendix E: Special Floating-Point Values
- Appendix E: Special Floating-Point Values
- Appendix F: Number Systems
- F.1: Introduction
- F.2: Conversions between Binary and Decimal Numbers
- F.3: Conversions between Hexadecimals and Decimal Numbers
- F.4: Conversions between Binary and Hexadecimal Numbers
- Appendix G: Bitwise Operations
- Appendix G: Bitwise Operations
- Appendix H: Regular Expressions
- Appendix H: Regular Expressions
- Appendix I: Enumerated Types
- Appendix I: Enumerated Types
- Appendix J: The Big-O, Big-Omega, and Big-Theta Notations
- Appendix J: The Big-O, Big-Omega, and Big-Theta Notations
- Symbol Index
- Symbol Index
- Supplemental Material
- Source Code and Solutions
- Download Software
- Supplements
- Debugging (Common Errors)
- Footnotes
- Glossary