Table of Contents
CIS 5930-04 – Spring 2001
Java Language Basics
Obvious similarities to C, C++
Obvious differences from C, C++
Primitive types rationalized
Three kinds of comments in Java
Documentation Comments
Java Keywords
Java Language—Program Structure
Java Types
Primitive Types
Reference Types
Strings—an Example of a Class Type
A Constructor Function
Some features of Strings.
Operations on Strings.
Array Types
Subscripts
Arrays of Objects
Multidimensional Arrays
Java Language—Expressions
Java Language—More Expressions
Java Control Flow. I: if Statements
Control Flow II: while Loop Constructs
Control Flow III: The for Loop Construct
Control Flow IV: The switch Construct
Control Flow V: break and continue
The Java Object Model: Classes, Instances and Methods
The Java Object Model Overview
Defining a Class
Example: a Predefined Class
Creating a Class Instance
Using a Class
Instance Variables
Class Variables
Method Definitions
Local variables
Static and Non-static Methods
Instance Methods
Invoking an Instance method
this
this as a prefix
Static Methods
Constructors
A Better Potato
Remarks
Type Conversions
Overloading
Calling an Overloaded Method
Examples of overload resolution
Header of Class Definition—Details
Modifiers of Classes
Modifiers of Fields
Modifiers of Methods
The Java Object Model: Inheritance and the Class Hierarchy
Some Dependencies between Classes
Inheritance
Trivial use of Inheritance
A Limited Kind of Polymorphism
Class Hierarchies
Inheritance with Overriding
True Polymorphism
Runtime Lookup of Methods
Inherited Methods and Overriding
Abstract Methods and Classes
Final Methods and Classes
Protected Access
The Universal Superclass—Object
Methods on the Object class
Reference Conversions
Simple Collections
A Vector is Like an Array
A Vector can Grow and Shrink
Using Vector
A HashMap is an Associative Array
Using HashMap
Widening Conversions on Arrays
Overloading with Inheritance
Overload Resolution across Classes
Summary: Overloading vs. Overriding
Constructors and Inheritance
Superclass Constructor Invocation
Exceptions
Exceptions are Pervasive
Exception Objects, and throw
throw compared with break
Methods that throw exceptions
Exception Handling in Nested Calls
Example using java.io
How (not) to Ignore an Exception
Part of the Exception Hierarchy
Unchecked Exceptions
Defining you own Exceptions
Interfaces
Abstract Classes Revisited
Interfaces
Implementing an interface
An Interface is a Contract
An Interface Defines a Type
Classes can Implement Several Interfaces
Interfaces can Extend other Interfaces
Interfaces can hold Constant Definitions
Interfaces can be used as Markers
Summary
Packages
Packages
Packages and Directory Structure (JDK)
Hierarchical Package Names
Fully Qualified Class Names
Import statements
CLASSPATH
Java System Packages, I
Java System Packages, II
Additional Java 1.2 System Packages
Further information
|