Specifications
Sun Services
Java™ Programming Language
viii
Copyright 2005 Sun Microsystems, Inc. All Rights Reserved. Sun Services, Revision F
Using the Enhanced for Loop ............................................................................................................ 5-13
Array Resizing ....................................................................................................................................... 5-14
Copying Arrays ..................................................................................................................................... 5-15
Class Design ............................................................................................................. 6-1
Objectives ................................................................................................................................................. 6-2
Relevance .................................................................................................................................................. 6-3
Subclassing ............................................................................................................................................... 6-4
Single Inheritance .................................................................................................................................... 6-7
Access Control ......................................................................................................................................... 6-9
Overriding Methods ............................................................................................................................. 6-10
Overridden Methods Cannot Be Less Accessible ............................................................................. 6-12
Invoking Overridden Methods ........................................................................................................... 6-13
Polymorphism ....................................................................................................................................... 6-15
Virtual Method Invocation .................................................................................................................. 6-17
Heterogeneous Collections .................................................................................................................. 6-18
Polymorphic Arguments ..................................................................................................................... 6-19
The instanceof Operator ................................................................................................................... 6-20
Casting Objects ...................................................................................................................................... 6-21
Overloading Methods .......................................................................................................................... 6-23
Methods Using Variable Arguments ................................................................................................. 6-24
Overloading Constructors ................................................................................................................... 6-25
Constructors Are Not Inherited .......................................................................................................... 6-27
Invoking Parent Class Constructors ................................................................................................... 6-28
Constructing and Initializing Objects: A Slight Reprise .................................................................. 6-30
Constructor and Initialization Examples ........................................................................................... 6-31
The Object Class .................................................................................................................................. 6-34
The equals Method .............................................................................................................................. 6-35
An equals Example ............................................................................................................................. 6-36
The toString Method ......................................................................................................................... 6-40










