Java Reference
In-Depth Information
• The method equals defines a notion of object equality, which is based on value, not
reference, comparison.
• The method finalize is run just before an object is destroyed (§ 12.6 ).
• 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
T is the class or interface searched (§ 15.12.1 ) for getClass .
A class method that is declared synchronized 8.4.3.6 ) synchronizes on the monitor
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.
String literals (§ 3.10.5 ) are references to instances of class String .
The string concatenation operator + 15.18.1 ) implicitly creates a new String object when
the result is not a compile-time constant expression (§ 15.28 ) .
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
13.1 ) and their type arguments, if any, are the same, applying this definition recursively.
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.
Search WWH ::




Custom Search