Static or class methods are available to all objects created from a class. In that sense, they are global | |||||||||
They are referenced as classname.method rather than objectname.method | |||||||||
Static/class methods -
| |||||||||
Example -- public class Gizmo |
![]()
| Overloading - Having 2 or more methods with the same name; they differ
by the type and number of parameters -- Unique
parameter lists are the key public class TV | |
| Use -- private TV tv; |
![]()
| this is a reference that always refers to the current object; same as in C++, but with "." instead of "->" | |
| It is used primarily to eliminate ambiguity | |
| It is also used to eliminate passing the current object as a parameter when another object of the same type is passed to a method | |
| Example -- public class Gizmo // a class
definition public Gizmo(int length, int width, int depth) //a
constructor
Download aspectRatio source
code - pay particular attention to the code behind the Movie, Square, and TV
buttons
Last updated by DrB on Wednesday, February 18, 2009
|