Originally posted by Maulin Vasavada:
String s = "maulin" + "vasavada" then maulin is in one string and vasavada is in another and both of them are in String "Literal Pool" and we don't have a way to get reference to it.
Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
Originally posted by Maulin Vasavada:
moderators,
i observe one behavior (or mis-behavior?) in URL UBB tag.
that is- if we put () in the the url then it doesn't work and i get HTML Error that says "Perenthesis in HTML".
so i can't post URL that is directly pointing to a method in the API as i wanted it to point to String.intern() method in above case...
regards
maulin
Originally posted by Maulin Vasavada:
well,
if u do,
String s = "maulin" + "vasavada" then maulin is in one string and vasavada is in another and both of them are in String "Literal Pool" and we don't have a way to get reference to it.
if we do,
String s1 = "maulin";
String s2 = "vasavada";
String s = s1 + s2;
then we have a reference to s1 and s2 even after adding them and making string s.
Originally posted by Namaste Sathi:
Suppose, we do s1 = s1 + "vasa"; what happens?
does it change s1 or create another new s1 with new value?if it creates s1 with new value how can we refer back to s1 with it's original value?
thanks.
Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Originally posted by Michael Morris:
What happens in the above scenario is a StringBuffer is created in which the string that is initially referred to by s1 is concatenated with (added to) the literal string "vasa". Then the toString() method of StringBuffer returns a new String object which is assigned to s1.
Originally posted by Namaste Sathi:
hey Michael,
i don't think above scenario creates a StringBuffer. i think it might create s1 with new value but i am wondering what happens to the original value of s1.
Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher