aspose file tools*
The moose likes Beginning Java and the fly likes object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "object" Watch "object" New topic
Author

object

thinakaran thinakaran
Greenhorn

Joined: Mar 28, 2003
Posts: 8
why java having object class?
What is the use of that
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Because we don't want any orphan classes Every class in Java has Object as an ancestor. Certain methods vital to the VM and other classes are defined there. Such as wait() and notify() which are used to control access to other objects by multiple threads. Also the equals() and hashCode() methods which are important to collections backed by hashmaps. And of course, every debuggers favorite, the toString() method. There are others too, like clone(), finalize() and getClass() (which allows us to use the Reflection API to reveal fields and methods of a class). So, as you see, the granddaddy Object class plays an important role in every Java programmers life, whether he realizes it or not.
Michael Morris


Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 4419
    
    5

Here's one article that discusses the implications of having a single-rooted hierarchy of classes like Java does as opposed to C++, which doesn't.


Junilu - [How to Ask Questions] [How to Answer Questions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: object
 
Similar Threads
Array
Thread and Object
generics - why does this work?
MultiDimenaional Array sort
WA #1.....word association