Object


Object java.lang

Java 1.0

This is the root class in Java. All classes are subclasses of Object , and thus all objects can invoke the public and protected methods of this class. For classes that implement the Cloneable interface, clone( ) makes a byte-for-byte copy of an Object . getClass( ) returns the Class object associated with any Object , and the notify( ) , notifyAll( ) , and wait( ) methods are used for thread synchronization on a given Object .

A number of these Object methods should be overridden by subclasses of Object . For example, a subclass should provide its own definition of the toString( ) method so that it can be used with the string concatenation operator and with the PrintWriter.println( ) methods. Defining the toString( ) method for all objects also helps with debugging.

The default implementation of the equals( ) method simply uses the = = operator to test whether this object reference and the specified object reference refer to the same object. Many subclasses override this method to compare the individual fields of two distinct objects (i.e., they override the method to test for the equivalence of distinct objects rather than the equality of object references). Some classes, particularly those that override equals( ) , may also want to override the hashCode( ) method to provide an appropriate hashcode to be used when storing instances in a Hashtable data structure.

A class that allocates system resources other than memory (such as file descriptors or windowing system graphic contexts) should override the finalize( ) method to release these resources when the object is no longer referred to and is about to be garbage-collected .

 public class  Object  {  // Public Constructors  public  Object  ( );  empty   // Public Instance Methods  public boolean  equals  (Object  obj  );        public final Class<? extends Object>  getClass  ( );  native  public int  hashCode  ( );  native  public final void  notify  ( );  native  public final void  notifyAll  ( );  native  public String  toString  ( );        public final void  wait  ( ) throws InterruptedException;        public final void  wait  (long  timeout  ) throws InterruptedException;  native  public final void  wait  (long  timeout  , int  nanos  ) throws InterruptedException;  // Protected Instance Methods  protected Object  clone  ( ) throws CloneNotSupportedException;  native  protected void  finalize  ( ) throws Throwable;  empty  } 

Subclasses

Too many classes to list.

Passed To

Too many methods to list.

Returned By

Too many methods to list.

Type Of

java.io.Reader.lock , java.io.Writer.lock , java.util.EventObject.source , java.util.Vector.elementData , java.util.prefs.AbstractPreferences.lock



Java In A Nutshell
Java In A Nutshell, 5th Edition
ISBN: 0596007736
EAN: 2147483647
Year: 2004
Pages: 1220

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net