Overview | Package | Class | Tree | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## java.lang
Class Object

    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.

Since:
  JDK1.0
Version:
  1.54, 02/02/00
Author:
  unascribed, Helge Böhme
Available on JControl Devices:

  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

### Object

    public Object()

Method Detail

### clone

    protected Object clone()
                    throws CloneNotSupportedException

  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 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()

  Returns:
    a clone of this instance.
  Throws:
    `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.
  See Also:
    `Cloneable`

### equals

    public boolean equals(Object obj)

  Indicates whether some other object is "equal to" this one.

  The `equals` method implements an equivalence relation:

  - It is reflexive: for any reference value `x`, `x.equals(x)` should return `true`.
  - It is symmetric: for any reference values `x` and `y`, `x.equals(y)` should return `true` if and only if `y.equals(x)` returns `true`.
  - It is transitive: for any reference values `x`, `y`, and `z`, if `x.equals(y)` returns `true` and `y.equals(z)` returns `true`, then `x.equals(z)` should return `true`.
  - It is consistent: for any reference values `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.
  - For any non-null reference value `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`).

  Parameters:
    `obj` - the reference object with which to compare.
  Returns:
    `true` if this object is the same as the obj argument; `false` otherwise.

### notifyAll

    public final void notifyAll()

  Wakes up all threads that are waiting on this object's monitor. A thread waits on an object's monitor by calling one of the `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:

  - By executing a synchronized instance method of that object.
  - By executing the body of a `synchronized` statement that synchronizes on the object.
  - For objects of type `Class,` by executing a synchronized static method of that class.

  Only one thread at a time can own an object's monitor.

  Throws:
    `IllegalMonitorStateException` - if the current thread is not the owner of this object's monitor.
  See Also:
    `wait()`

### wait

    public final void wait()
                    throws InterruptedException

  Causes current thread to wait until another thread invokes the `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.

  Throws:
    `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.
  See Also:
    `notifyAll()`

Overview | Package | Class | Tree | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD