aspose file tools*
The moose likes Java in General and the fly likes java Object class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "java Object class" Watch "java Object class" New topic
Author

java Object class

Gaurav Bohra
Greenhorn

Joined: Mar 24, 2004
Posts: 1
why Object is always a super class of all java classes.
what is the problem if java don't use Object as super class of all classes
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

Sometimes you like to compare objects, which aren't from the same class.
You may have cats and mice.
Both are (implicitly) derived from Object.
Object has a method 'boolean equals (Object compared)'.
Since mice and cats are object, you may call

Both comparisions will return false, while 'equals' isn't overriden.
In this way, every method may expect a parameter of type 'Object', giving you a great flexibility.
Some methods are used for Thread-handling. (wait, notify, ...).
The toString () - Method is useful for debugging.
The getClass () - Method is used in reflection.
Look at the javadocs for the methods, and a good beginners-book for the description of the usage.
The second question can't be answered. You cannot remove 'Object' everything depends on it. To keep almost all the functionality you would need alternatives. Of course other oo - languages exist with other concepts, but that's beyond my level. Perhaps it's interesting, to have a look at 'C#' (looks very similar to me), which is a newer Language, and c++ which is older - c++ doesn't have an super-root: Object, and I don't know, how reflection is handled there.
Smalltalk and Lisp are other oo - languages to have a look.


http://home.arcor.de/hirnstrom/bewerbung
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java Object class