Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 917 trang
THÔNG TIN TÀI LIỆU
Cấu trúc
Cover
Title Page
Copyright
Contents
Preface
Chapter 1 Introduction
1.1 The Java Programming Language
A Java Program
Comments
Identifiers and Reserved Words
White Space
1.2 Program Development
Programming Language Levels
Editors, Compilers, and Interpreters
Development Environments
Syntax and Semantics
Errors
1.3 Problem Solving
1.4 Software Development Activities
1.5 Object-Oriented Programming
Object-Oriented Software Principles
Chapter 2 Data and Expressions
2.1 Character Strings
The print and println Methods
String Concatenation
Escape Sequences
2.2 Variables and Assignment
Variables
The Assignment Statement
Constants
2.3 Primitive Data Types
Integers and Floating Points
Characters
Booleans
2.4 Expressions
Arithmetic Operators
Operator Precedence
Increment and Decrement Operators
Assignment Operators
2.5 Data Conversion
Conversion Techniques
2.6 Reading Input Data
The Scanner Class
Chapter 3 Using Classes and Objects
3.1 Creating Objects
Aliases
3.2 The String Class
3.3 Packages
The import Declaration
3.4 The Random Class
3.5 The Math Class
3.6 Formatting Output
The NumberFormat Class
The DecimalFormat Class
The printf Method
3.7 Enumerated Types
3.8 Wrapper Classes
Autoboxing
Chapter 4 Conditionals and Loops
4.1 Boolean Expressions
Equality and Relational Operators
Logical Operators
4.2 The if Statement
The if-else Statement
Using Block Statements
The Conditional Operator
Nested if Statements
4.3 Comparing Data
Comparing Floats
Comparing Characters
Comparing Objects
4.4 The switch Statement
4.5 The while Statement
Infinite Loops
Nested Loops
Other Loop Controls
4.6 Iterators
Reading Text Files
4.7 The do Statement
4.8 The for Statement
Iterators and for Loops
Comparing Loops
Chapter 5 Writing Classes
5.1 Classes and Objects Revisited
Identifying Classes and Objects
Assigning Responsibilities
5.2 Anatomy of a Class
Instance Data
UML Class Diagrams
5.3 Encapsulation
Visibility Modifiers
Accessors and Mutators
5.4 Anatomy of a Method
The return Statement
Parameters
Local Data
Constructors Revisited
5.5 Static Class Members
Static Variables
Static Methods
5.6 Class Relationships
Dependency
Dependencies Among Objects of the Same Class
Aggregation
The this Reference
5.7 Method Design
Method Decomposition
Method Parameters Revisited
5.8 Method Overloading
5.9 Testing
Reviews
Defect Testing
Unit Testing
Integration Testing
System Testing
Test-Driven Development
5.10 Debugging
Simple Debugging with print Statements
Debugging Concepts
Chapter 6 Graphical User Interfaces
6.1 GUI Elements
Frames and Panels
Buttons and Action Events
Determining Event Sources
6.2 More Components
Text Fields
Check Boxes
Radio Buttons
Sliders
Combo Boxes
Timers
6.3 Layout Managers
Flow Layout
Border Layout
Grid Layout
Box Layout
Containment Hierarchies
6.4 Mouse and Key Events
Mouse Events
Key Events
Extending Adapter Classes
6.5 Dialog Boxes
File Choosers
Color Choosers
6.6 Some Important Details
Borders
Tool Tips and Mnemonics
6.7 GUI Design
Chapter 7 Arrays
7.1 Array Elements
7.2 Declaring and Using Arrays
Bounds Checking
Alternate Array Syntax
Initializer Lists
Arrays as Parameters
7.3 Arrays of Objects
7.4 Command-Line Arguments
7.5 Variable-Length Parameter Lists
7.6 Two-Dimensional Arrays
Multidimensional Arrays
Chapter 8 Inheritance
8.1 Creating Subclasses
The protected Modifier
The super Reference
Multiple Inheritance
8.2 Overriding Methods
Shadowing Variables
8.3 Class Hierarchies
The Object Class
Abstract Classes
8.4 Visibility
8.5 Designing for Inheritance
Restricting Inheritance
Chapter 9 Polymorphism
9.1 Late Binding
9.2 Polymorphism via Inheritance
9.3 Interfaces
Interface Hierarchies
The Comparable Interface
The Iterator Interface
9.4 Polymorphism via Interfaces
Event Processing
Chapter 10 Exceptions
10.1 Exception Handling
10.2 Uncaught Exceptions
10.3 The try-catch Statement
The finally Clause
10.4 Exception Propagation
10.5 The Exception Class Hierarchy
Checked and Unchecked Exceptions
10.6 I/O Exceptions
Chapter 11 Recursion
11.1 Recursive Thinking
Infinite Recursion
Recursion in Math
11.2 Recursive Programming
Recursion vs. Iteration
Direct vs. Indirect Recursion
11.3 Using Recursion
Traversing a Maze
The Towers of Hanoi
Chapter 12 Analysis of Algorithms
12.1 Algorithm Efficiency
12.2 Growth Functions and Big-Oh Notation
12.3 Comparing Growth Functions
Method Calls
Analyzing Recursive Algorithms
Chapter 13 Searching and Sorting
13.1 Searching
Linear Search
Binary Search
13.2 Sorting
Selection Sort
Insertion Sort
Bubble Sort
Quick Sort
Merge Sort
13.3 Analyzing Searching and Sorting Algorithms
Comparing Search Algorithms
Comparing Sort Algorithms
Chapter 14 Stacks
14.1 Introduction to Collections
Abstract Data Types
The Java Collections API
14.2 A Stack Collection
14.3 Inheritance, Polymorphism, and Generics
Generics
14.4 A Stack ADT
14.5 Using Stacks: Evaluating Postfix Expressions
14.6 Exceptions
14.7 Implementing a Stack: with Arrays
Managing Capacity
14.8 The ArrayStack Class
The push Operation
The pop Operation
The peek Operation
Other Operations
14.9 References as Links
14.10 Managing Linked Lists
Accessing Elements
Inserting Nodes
Deleting Nodes
Sentinel Nodes
14.11 Elements Without Links
Doubly Linked Lists
14.12 Implementing a Stack: With Links
The LinkedStack Class
The push Operation
The pop Operation
Other Operations
14.13 Implementing Stacks: The Java.Util.Stack Class
Unique Operations
Inheritance and Implementation
14.14 Packages
Organizing Packages
Using CLASSPATH
Chapter 15 Queues
15.1 A Queue ADT
15.2 Using Queues: Code Keys
15.3 Using Queues: Ticket Counter Simulation
15.4 Implementing Queues: With Links
The enqueue Operation
The dequeue Operation
Other Operations
15.5 Implementing Queues: With Arrays
The enqueue Operation
The dequeue Operation
Other Operations
Chapter 16 Trees
16.1 Tree Terminology
Tree Classifications
16.2 Tree Traversals
Preorder Traversal
Inorder Traversal
Postorder Traversal
Level-Order Traversal
16.3 Strategies for Implementing Trees
Computed Links in an Array
Stored Links in an Array
Linked Nodes
16.4 A Binary Tree Implementation
16.5 Decision Trees
Chapter 17 Binary Search Trees
17.1 Binary Search Trees
Adding an Element to a Binary Search Tree
Removing an Element from a Binary Search Tree
17.2 Binary Search Tree Implementation
17.3 Balanced Binary Search Trees
Right Rotation
Left Rotation
Right-Left Rotation
Left-Right Rotation
Chapter 18 Heaps and Priority Queues
18.1 Heaps
Adding an Element to a Heap
Removing the Largest Element from a Heap
18.2 Heap Implementation
18.3 Heap Sort
18.4 Priority Queues
Chapter 19 Graphs
19.1 Undirected Graphs
19.2 Directed Graphs
19.3 Weighted Graphs
19.4 Common Graph Algorithms
Traversals
Testing for Connectivity
Minimum Spanning Trees
Determining the Shortest Path
19.5 Strategies for Implementing Graphs
Adjacency Lists
Adjacency Matrices
Chapter 20 Hashing
20.1 Hashing
20.2 Hashing Functions
The Division Method
The Folding Method
The Mid-square Method
The Radix Transformation Method
The Digit Analysis Method
The Length-Dependent Method
Hashing Functions in the Java Language
20.3 Resolving Collisions
Chaining
Open Addressing
20.4 Deleting Elements from A Hash Table
Deleting from a Chained Implementation
Deleting from an Open Addressing Implementation
20.5 Hash Tables in the Java Collections API
The Hashtable Class
The HashSet Class
The HashMap Class
The IdentityHashMap Class
The WeakHashMap Class
LinkedHashSet and LinkedHashMap
Chapter 21 Databases
21.1 Introduction to Databases
21.2 Establishing a Connection to a Database
Obtaining A Database Driver
21.3 Creating and Altering Database Tables
Create Table
Alter Table
Drop Column
21.4 Querying The Database
Show Columns
21.5 Inserting, Viewing, and Updating (Modifying) Data
Insert
Select . . . from
Update
21.6 Deleting Data and Database Tables
Deleting Data
Deleting Database Tables
Appendix A: Glossary
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
Z
Appendix B: Number Systems
Place Value
Bases Higher Than 10
Conversions
Shortcut Conversions
Appendix C: The Unicode Character Set
Appendix D: Java Bitwise Operators
Appendix E: Java Modifiers
Java Visibility Modifiers
A Visibility Example
Other Java Modifiers
Appendix F: Java Graphics
Coordinate Systems
Representing Color
Drawing Shapes
Polygons and Polylines
The Polygon Class
Appendix G: Java Applets
Embedding Applets in HTML
More Applet Methods
GUIs in Applets
Appendix H: Regular Expressions
Appendix I: Javadoc Documentation Generator
Doc Comments
Tags
Files Generated
Appendix J: Java Syntax
Index
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
Nội dung
[...]... the material upon which this xi xii PR EFA C E book is based There are too many of you to individually name, but your influence on Java Software Solutions and Java Software Structures is evident in Java Foundations Special thanks go to Ruth Dannenfelser, Cory Samaha, and Zach Zappala at the College of New Jersey for their help with solutions to the database projects And our continued thanks go to Jason... Expressions 837 Appendix I Javadoc Documentation Generator 839 Doc Comments 840 Tags 841 Files Generated 841 Appendix J Java Syntax 845 Index 859 xxv This page intentionally left blank Second Edition Java Foundations ™ Introduction to Program Design & Data Structures This page intentionally left blank Introduction 1 CHAPTER OBJECTIVES ■ Introduce the Java programming language ■ Describe the steps involved... software We begin by examining a very basic Java program and using it to explore some initial programming concepts We then lay the groundwork for software development on a larger scale, exploring the foundations of problem solving, the activities involved in software development, and the principles of object-oriented programming 1 2 C HA PT ER 1 Introduction 1.1 The Java Programming Language A computer... Like a class definition, a method is also delimited by braces 3 4 C HA PT ER 1 L I S T I N G Introduction 1 1 //******************************************************************** // Lincoln.java Java Foundations // // Demonstrates the basic structure of a Java application //******************************************************************** public class Lincoln { // .