This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes object's methods 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's methods

RajivAwadhesh kumar
Greenhorn

Joined: May 20, 2011
Posts: 24
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
Bartender

Joined: May 31, 2011
Posts: 1776
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

Joined: Mar 17, 2011
Posts: 7896
    
  21

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


Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4398
    
    8

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.
 
GeeCON Prague 2014
 
subject: object's methods