CSS446 Spring 2014 Nan Wang
Jan 02, 2016
To be able to declare and use interface types
To appreciate how interfaces can be used to decouple classes
To learn how to implement helper as inner classes
2
Upcasting, can convert from a class type to the type of any interface that the class implements (automatically).
Downcasting, interfaceclasses
If the object(max) doesn’t actually refer to a country, a run time exception will occur.
3
Invoking Methods on Interface VariablesThe Java virtual machine locates the correct method by first looking at the class of the actual object, and then calling the method with the given name in that class.
4
A Measurable interface is used to measuring a single object.
The Comparable inter face compares two objects.
Return a negative number if a should come before b, zero if a and b are the same, and a positive number if b should come before a.
Comparable interface
5
Once the BankAccount class implements the Comparable interface, can sort bank accounts array with the Arrays.sort method
6
A callback is a mechanism for bundling up a block of code so that it can be invoked at a later time.
8
A class that is declared inside another class is called an inner class.
The inner class is available to all methods of the enclosing class.
Execute file: outerclassName$innerclassName.exe
9