Raghu J<br />SCJP 1.4<br /> <br />The Wind and waters are always<br />on the side of the ablest navigators.<br /><a href="http://groups.yahoo.com/group/scjp_share" target="_blank" rel="nofollow">SCJP Group</a><br /><a href="http://groups.yahoo.com/group/JavaBeat_SCWCD" target="_blank" rel="nofollow">SCWCD Group</a>
Raghu J<br />SCJP 1.4<br /> <br />The Wind and waters are always<br />on the side of the ablest navigators.<br /><a href="http://groups.yahoo.com/group/scjp_share" target="_blank" rel="nofollow">SCJP Group</a><br /><a href="http://groups.yahoo.com/group/JavaBeat_SCWCD" target="_blank" rel="nofollow">SCWCD Group</a>
SCJP 1.5(Done) SCJA 1.0(Done)<br />SCWCD(in Progress...)
SCJP 1.5(Done) SCJA 1.0(Done)<br />SCWCD(in Progress...)
"I'm not back." - Bill Harding, Twister
since String object is immutable everytime you call toString() method it will create a different String object, even if values are the same, so b1.toString() will create different String objects with same value but different object reference over and over again.
Raghu J<br />SCJP 1.4<br /> <br />The Wind and waters are always<br />on the side of the ablest navigators.<br /><a href="http://groups.yahoo.com/group/scjp_share" target="_blank" rel="nofollow">SCJP Group</a><br /><a href="http://groups.yahoo.com/group/JavaBeat_SCWCD" target="_blank" rel="nofollow">SCWCD Group</a>
"I'm not back." - Bill Harding, Twister
SCJP 1.5(Done) SCJA 1.0(Done)<br />SCWCD(in Progress...)
Originally posted by levani dvalishvili:
I think that overall for small reasons caching is a bad idea I agreee with sun on not caching. here is what I think
for example
String s1 = "hello";
String s2 = "hello";
String s3 = "hello";
my question is should all these strings be using one "hello" or should they be three different objects? if answer is no than its a overhead of JVm before creating an object to make sure that object with that specific value does not already exists .....
same thing with altering a Byte to cache the String...
this is just what I think
very truly
levani
SCJP 1.4<br />SCJD <br />SCWCD (Studying)
SCJP 1.5(Done) SCJA 1.0(Done)<br />SCWCD(in Progress...)
Don't get me started about those stupid light bulbs. |