| Book Description
About the Author
Table of Contents
Source Code
Errata
Send Comments
Teaching Materials
Author's Homepage
|
Object-Oriented
Software Development Using Java
Xiaoping
Jia, Ph.D
Chapter
4: Elements of Java
Contents
4.1 Lexical Elements
4.1.1 Character Set
4.1.2 Identifiers
4.1.3 Primitive Types and
Literals
4.1.4 Operators and Expressions
4.2 Variables and Types
4.2.1 Variable Declarations
4.2.2 Type Compatibility and
Conversion
4.2.3 Reference Types
4.2.4 Arrays
4.3 Statements
4.3.1 Expression Statements
4.3.2 Statement Blocks
4.3.3 Local Variable
Declarations
4.3.4 The return Statement
4.3.5 Selection Statements
4.3.6 Loop Statements
4.3.7 The break and continue
Statements
4.4 Class Declarations
4.4.1 Syntax of Class
Declarations
4.4.2 Creating and Initializing
Objects
4.4.3 Accessing Fields and
Methods
4.4.4 Method Invocation and
Parameter Passing
4.4.5 Class (Static) Fields and
Methods
4.4.6 Object Reference this
4.4.7 Interfaces and Abstract
Classes
4.4.8 Strings
4.4.9 Wrapper Classes
4.5 Packages
4.5.1 Using Packages
4.5.2 Partitioning the Name
Space
4.5.3 Packages and the
Directory Structure
4.5.4 Organization of the Java
Class Library
4.6 Exceptions
4.6.1 Sources of Exceptions
4.6.2 Hierarchy of Exceptions
4.6.3 Throwing Exceptions
4.6.4 Catching and Handling
Exceptions
4.7 A Simple Animation Applet
-
Example 4.1 The Sum of an Array of Integers
-
Example 4.2 Sorting an One-Dimentional Array Using Bubble Sort
- Example 4.3 Command Line Arguments
-
Example 4.4 Copying from Standard Input to Standard Output
-
Source code: Copy.java
-
Compile:
-
Run:
java Copy < infile.txt > outfile.txt
-
Example 4.5 Copying Text Files
-
Source code: CopyTextFile.java
-
Compile:
-
Run:
java CopyTextFile infile.txt outfile.txt
-
Example 4.6 Breaking Colon-Delimited Records
-
Example 4.7 Breaking Text into Words
-
Example 4.8 The Minimum of an Array of Integers
-
Example 4.9 The Max-Min Value of a Two-Dimensional Array
-
Example 4.10 Digital Clock Applet
Other Examples
-
Class and instance fields
-
Singleton class
-
String comparison
Book Description - About
the Author - Table of Contents
Source
Code - Errata - Send
Comments
Teaching Materials - Author's
Homepage
|