I know Life is very Tough...But I AM TOUGHER
SCJP 1.5
In the above code two objects will be created.one string object placed in non string constant pool(s.c.p). literal "abc" placed in string constant pool
SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
NagarajGoud uppala wrote:Hi,
In the above code two objects will be created.one string object placed in non string constant pool(s.c.p). literal "abc" placed in string constant pool.where this string constant pool present? in heap only? or it is separate memory? please any one show me diagrammatically how the single reference 's' point to two objects(one in s.c.p,another n.s. c.p).
I know Life is very Tough...But I AM TOUGHER
SCJP 1.5
Two objects will be created but your explanation seems incorrect. String constant pool is just a collection of references to String objects. When you say "new String()" JVM is forced to create another object despite the String literal "abc".
I know Life is very Tough...But I AM TOUGHER
SCJP 1.5
NagarajGoud uppala wrote:But i think two objects because one string object will be created which is referred by 's' and "abc" literal also create one object.isn't it??
SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
I know Life is very Tough...But I AM TOUGHER
SCJP 1.5
Mo Jay wrote:I have NO idea where the concept of creating 2 string objects came from.
SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Think of how dumb the average person is. Mathematically, half of them are EVEN DUMBER. Smart tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
|