Objects

Back Up Next

 

Objects
Your basic Object
public String toString()
public boolean equals(Object o)
public int hashCode()
protected Object clone() throws CloneNotSupportedException
Examples of Objects
//
//valid object expression statements
//
Object o;
String s = "Welcome to the party!";
myClass cls = new myClass(s);
Hashtable stuff = new Hashtable();
double weights[] = new double[30];
char chessboard[][] = new char[8][8];
stuff.put("A", cls);
cls = (myClass)stuff.get("A");
cls.getName().equals(s);
Objects are references instead of pointers
Use the new operator to create objects
You don't delete objects - garbage collection does it for you automatically
Arrays are special, non-inheritable Objects