Java Reference
In-Depth Information
this reference A reference to the current object. It can be used to send the cur-
rent object, as a unit, to some other method. (79)
toString method Returns a String based on the object state. (78)
common errors
1. Private members cannot be accessed outside of the class. Remember that,
by default, class members are package visible: They are visible only
within the package.
2. Use public class instead of class unless you are writing a throw-away
helper class.
3. The formal parameter to equals must be of type Object . Otherwise,
although the program will compile, there are cases in which a default
equals (that simply mimics == ) will be used instead.
4. Static methods cannot access nonstatic members without a controlling
object.
5. Classes that are part of a package must be placed in an identically named
directory that is reachable from the CLASSPATH .
6. this is a final reference and may not be altered.
7.
Constructors do not have return types. If you write a “constructor” with
return type void , you have actually written a method with the same name
as the class, but this is NOT a constructor.
on the internet
Following are the files that are available:
TestIntCell.java
Contains a main that tests IntCell , shown in
Figure 3.3.
IntCell.java
Contains the IntCell class, shown in Figure 3.4.
The output of javadoc can also be found as
IntCell.html .
Date.java
Contains the Date class, shown in Figure 3.6.
BigRational.java
Contains the BigRational class, shown in Section 3.7
and found in package weiss.math.
Ticket.java
Contains the Ticket static member example in
Figure 3.9.
Squares.java
Contains the static initializer sample code in
Figure 3.10.
 
Search WWH ::




Custom Search