Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

object's methods

 
RajivAwadhesh kumar
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Each object has its own values for instance variables. What about object's methods?
How and where are object's stored? How are the object's methods called from where the object is stored?
Please suggest any article or tutorial about how an object is made, stored and details of how instance variables, static members of a class and instance methods are stored?
 
John Jai
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could sure read them from a good Java beginner's book or rather search each question using Google.
And a search for older threads in this forum yields lot of useful threads...
http://www.coderanch.com/t/416620/java/java/stored-Stack-Heap
 
Winston Gutkowski
Bartender
Pie
Posts: 10417
63
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
RajivAwadhesh kumar wrote:Each object has its own values for instance variables. What about object's methods?
How and where are object's stored? How are the object's methods called from where the object is stored?
Please suggest any article or tutorial about how an object is made, stored and details of how instance variables, static members of a class and instance methods are stored?
The fact is: you don't need to know; and in many cases these details are JVM-specific, so any answer we give you for one might not be true on another.
Java is NOT like C or C++, where understanding how objects are arranged in memory can give you some insights into how to code. In Java it's more likely to (a) distract you from what you're supposed to be doing (ie, programming), and (b) lead you down the path to dangerously brittle code.

One thing I will tell you is that methods (both static and non) are stored separately from object contents, and that usually only ONE copy of a method (again, both static and non) is kept per class...although when generics gets involved, I may not even be correct there.

Winston
 
Matthew Brown
Bartender
Posts: 4567
8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Winston Gutkowski wrote:...although when generics gets involved, I may not even be correct there.

I suspect you are correct, since the generic information is lost at run-time so I don't think there'd be a need for multiple versions.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic