|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Object
public class Object
Class Object is the root of the class hierarchy.
Every class has Object as a superclass. All objects,
including arrays, implement the methods of this class.
| all |
| Constructor Summary | |
|---|---|
Object()
|
|
| Method Summary | |
|---|---|
protected Object |
clone()
Creates and returns a copy of this object. |
boolean |
equals(Object obj)
Indicates whether some other object is "equal to" this one. |
void |
notifyAll()
Wakes up all threads that are waiting on this object's monitor. |
void |
wait()
Causes current thread to wait until another thread invokes the notifyAll() method for this object. |
| Constructor Detail |
|---|
public Object()
| Method Detail |
|---|
protected Object clone()
throws CloneNotSupportedException
x, the expression:
will be true, and that the expression:x.clone() != x
will bex.clone().getClass() == x.getClass()
true, but these are not absolute requirements.
While it is typically the case that:
will bex.clone().equals(x)
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 internal data
structures as well. No constructors are called.
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 a
CloneNotSupportedException is thrown. Note that all arrays
are considered to implement the interface Cloneable.
Otherwise, this method creates a new instance of the class of this
object and initializes all its fields with exactly the contents of
the corresponding fields of this object, as if by assignment; the
contents of the fields are not themselves cloned. Thus, this method
performs a "shallow copy" of this object, not a "deep copy" operation.
The class Object does not itself implement the interface
Cloneable, so calling the clone method on an object
whose class is Object will result in throwing an
exception at run time. The clone method is implemented by
the class Object as a convenient, general utility for
subclasses that implement the interface Cloneable, possibly
also overriding the clone method, in which case the
overriding definition can refer to this utility definition by the
call:
super.clone()
CloneNotSupportedException - if the object's class does not
support the Cloneable interface. Subclasses
that override the clone method can also
throw this exception to indicate that an instance cannot
be cloned.
java.lang.OutOfMemoryError - if there is not enough memory.Cloneablepublic boolean equals(Object obj)
The equals method implements an equivalence relation:
x,
x.equals(x) should return true.
x and
y, x.equals(y) should return
true if and only if y.equals(x) returns
true.
x,
y, and z, if x.equals(y)
returns true and y.equals(z) returns
true, then x.equals(z) should return
true.
x
and y, multiple invocations of x.equals(y)
consistently return true or consistently return
false, provided no information used in
equals comparisons on the object is modified.
x,
x.equals(null) should return false.
The equals method for class Object implements
the most discriminating possible equivalence relation on objects;
that is, for any reference values x and y,
this method returns true if and only if x and
y refer to the same object (x==y has the
value true).
obj - the reference object with which to compare.
true if this object is the same as the obj
argument; false otherwise.public final void notifyAll()
wait methods.
The awakened threads will not be able to proceed until the current thread relinquishes the lock on this object. The awakened threads will compete in the usual manner with any other threads that might be actively competing to synchronize on this object; for example, the awakened threads enjoy no reliable privilege or disadvantage in being the next thread to lock this object.
This method should only be called by a thread that is the owner of this object's monitor. A thread becomes the owner of the object's monitor in one of three ways:
synchronized statement
that synchronizes on the object.
Class, by executing a
synchronized static method of that class.
Only one thread at a time can own an object's monitor.
IllegalMonitorStateException - if the current thread is not
the owner of this object's monitor.wait()
public final void wait()
throws InterruptedException
notifyAll() method for this object.
In other words, this method behaves exactly as if it simply
performs the call wait(0).
The current thread must own this object's monitor. The thread
releases ownership of this monitor and waits until another thread
notifies threads waiting on this object's monitor to wake up
through a call to the
notifyAll method. The thread then waits until it can
re-obtain ownership of the monitor and resumes execution.
This method should only be called by a thread that is the owner
of this object's monitor. See the notifyAll method for a
description of the ways in which a thread can become the owner of
a monitor.
IllegalMonitorStateException - if the current thread is not
the owner of the object's monitor.
InterruptedException - if another thread has interrupted
the current thread. The interrupted status of the
current thread is cleared when this exception is thrown.notifyAll()
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||