20.1
java.lang.Object
THE PACKAGE JAVA.LANG
integer. The integer may be positive, negative, or zero. This integer does not,
however, have to remain consistent from one Java application to another, or
from one execution of an application to another execution of the same appli
cation.
If two objects are equal according to the
equals
method ( 20.1.3), then call
ing the
hashCode
method on each of the two objects must produce the same
integer result.
It is
not
required that if two objects are unequal according to the
equals
method ( 20.1.3), then calling the
hashCode
method on each of the two
objects must produce distinct integer results. However, the programmer
should be aware that producing distinct integer results for unequal objects
may improve the performance of hashtables.
As much as is reasonably practical, the
hashCode
method defined by class
Object
does return distinct integers for distinct objects. (This is typically imple
mented by converting the internal address of the object into an integer, but this
implementation technique is not required by the Java language.)
Overridden by
Boolean
( 20.4),
Character
( 20.5),
Integer
( 20.7),
Long
( 20.8),
Float
( 20.9),
Double
( 20.10),
String
( 20.12), and
Bitset
( 21.2).
20.1.5
protected Object clone()
throws CloneNotSupportedException
The general contract of clone is that it creates and returns a copy of this object.
The precise meaning of copy may depend on the class of the object. The general
intent is that, for any object
x
, the expression:
x.clone() != x
will be
true
, and that the expression:
x.clone.getClass() == x.getClass()
will be
true
, but these are not absolute requirements. While it is typically the case
that:
x.clone.equals(x)
will be
true
, this is not an absolute requirement. Copying an object will typically
entail creating a new instance of its class, but it also may require copying of inter
nal data structures as well.
The method
clone
for class
Object
performs a specific cloning operation.
First, if the class of this object does not implement the interface
Cloneable
, then
460
footer
Our partners:
PHP: Hypertext Preprocessor Best Web Hosting
Java Web Hosting
Inexpensive Web Hosting
Jsp Web Hosting
Cheapest Web Hosting
Jsp Hosting
Cheap Hosting
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved