String s1= "hello";//i believe 1 object is created in the heap
// namely s1 point to the value hello in constant pool.
String s2= s1; //s2 a reference variable created in stack( // correct me here as am not sure of this)and s2 points to // object s1 in the heap .
luke brown wrote:where are the methods local variable instance variable object stored in java.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
String s1= "hello"
String s2 = s1
But you haven't said where the memory area is.Tushar Goel wrote: . . . All the methods got memory in method area . . .
And where is this constant pool? In the class file or on the heap? You need a lot more explanation for people who are too inexperienced to know they don't need to know thisTushar Goel wrote: . . .
In this case 2 objects will be created, one in constant pool and other one in heap.
And if, like me (and many others here), you came from a language like C or C++ where this stuff is important, try and "unlearn" it if you can. You'll be much happier for it.
I am always surprised at the added knowledge i can get from others when i give my opinion on a topic.
But you haven't said where the method area is.
You need a lot more explanation for people who are too inexperienced to know they don't need to know this
Tushar Goel wrote:
But you haven't said where the method area is.
method area , constant pool and class info are part of class area.. in JLS 2.5.4 and 5 explains method area and constant pool..
Steve
Paul Ngom wrote:Winston, you are so right. I have also never bothered to learn where those things are stored. Does it help to know how a bicycle is engineered? Many of us just know how to ride it.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Mind sharing a link to what you actually got that information
Glad to see someone's got the message.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |