This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

object

 
thinakaran thinakaran
Greenhorn
Posts: 8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why java having object class?
What is the use of that
 
Michael Morris
Ranch Hand
Posts: 3451
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Junilu Lacar
Bartender
Pie
Posts: 6532
21
Java Linux Mac Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic