Local Data and Scope
The scope of a variable is the part of a program where the variable can be referenced.
A variable declared inside a function is local to the function, so its scope is just the function definition body. It is not known outside this scope. Eg. The variable faceName declared in the toString method of Coin class is a local data.
Formal parameters are local variables too, and have the function body as their scope.
Method overloading (review)
An example of overloaded function is the println method that can take as parameter a string, an int, a double, a char, a boolean, etc.
Special methods:
public boolean equals(Object o)
o1.equals(o2)
versus o1 == o2
The equals() method tests the equality of two
objects, meaning the equality of their states. It defines the equivalence of objects on a per-class basis, meaning both o1 and o2 refer to the same object.
The == operator tests the identity of two
objects. It refers to the equality of the two references, not the equality of
the states of the objects refered to by them.
When compare two strings, use s1.equals(s2)
instead of s1 == s2.
public String toString()
returns a string representation of the state of
the object
The StringTokenizer Class
This class is provided by the Java standard class library in the java.util package.This class allows a sting to be broken into tokens, based on a set of delimiters such as space, tab, end of line, .