Object Oriented Programming and Design in Java
Session 11 Instructor: Bert Huang
Object Oriented Programming and Design in Java Session 11 - - PowerPoint PPT Presentation
Object Oriented Programming and Design in Java Session 11 Instructor: Bert Huang Announcements Midterm review Monday, Mar. 8th Midterm exam Wednesday, Mar. 10 th Midterm sample problems posted on courseworks Review Inheritance
Session 11 Instructor: Bert Huang
courseworks
hashCode()
variables into types
whole story
compiler checks to validate type usage
weʼve discussed recently apply to types
for when a supertype variable is expected
types
subclass of T
T or one of its interfaces
component type of S is a subtype of the component type of T
subclass of T
T or one of its interfaces
component type of S is a subtype of the component type of T
boolean
initialization
locations
structure of references
component type of S is a subtype of the component type of T”
MouseListener []? No Yes
type, we can have arrays of arrays
not hierarchically connected to Integer []
types called enumerated types
values, but there is no order or numerical meaning to the values
WEST
as meaningless int values, use enum type
SOUTH, EAST, WEST };
“extends Enum”
class, java.lang.Object
automatically with the + operator on Strings
and the hash code in hexadecimal
something more useful
x.equals(z))
an actual copy of an Object instead of another reference
can only be used if your subclass implements the Cloneable interface
clone() are only on Cloneable objects
share common aggregated objects
then x.hashcode() == y.hashcode()
different objects (this is unavoidable)
about arrays and lists:
integer indices?
all possible keys 1 through K
1 2 3 4 5 6 ... K-3 K-2 K-1 K
array position
1 2 3 4 5 6 ... K-3 K-2 K-1 K 1 ... N-2 N-1
hashcode()
to the space of array indices is valid
the array
array locations