Java Reference
In-Depth Information
• The method
equals
defines a notion of object equality, which is based on value, not
reference, comparison.
• The method
getClass
returns the
Class
object that represents the class of the object.
A
Class
object exists for each reference type. It can be used, for example, to discov-
er the fully qualified name of a class, its members, its immediate superclass, and
any interfaces that it implements.
The type of a method invocation expression of
getClass
is
Class<? extends
|
T
|
>
where
associated with the
Class
object of the class.
• The method
hashCode
is very useful, together with the method
equals
, in hashtables
such as
java.util.Hashmap
.
• The methods
wait
,
notify
, and
notifyAll
are used in concurrent programming using
threads (§
17.2
).
• The method
toString
returns a
String
representation of the object.
4.3.3. The Class
String
Instances of class
String
represent sequences of Unicode code points.
A
String
object has a constant (unchanging) value.
4.3.4. When Reference Types Are the Same
Two reference types are the
same compile-time type
if they have the same binary name
When two reference types are the same, they are sometimes said to be the
same class
or the
same interface
.
At run time, several reference types with the same binary name may be loaded simultan-
eously by different class loaders. These types may or may not represent the same type
declaration. Even if two such types do represent the same type declaration, they are con-
sidered distinct.