java.lang
Class Object

java.lang.Object

public class Object

Advanced Placement Computer Science

Standard Disclaimer: This isn't the official javadoc version of java.lang.Object, it's the AP-friendly version.

The root of the Java class hierarchy.


Constructor Summary
Object()
           
 
Method Summary
 boolean equals(Object other)
          Determines if this object is "equal" to another object.
 int hashCode()
           
 String toString()
           
 

Constructor Detail

Object

public Object()
Method Detail

equals

public boolean equals(Object other)
Determines if this object is "equal" to another object.

In general, objects should be instances of the same class with the same guts to be considered equal. For example, the code below only prints same value since s and t are different strings though they have the same value: "hello".

 String s = new String("hello");
 String t = new String("hello");
 if (s.equals(t)) System.out.println("same value");
 if (s == t) System.out.println("same string");

 

Parameters:
is - the other Object to which this one is compared
Returns:
true if this Object is equal to other

toString

public String toString()

hashCode

public int hashCode()