This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Thanks for pointing to the String literal article. Interesting to note that c="a"+"b" will give you a different result as compared to c=a+b, even though they are both concat, a+b creates a new String object and is not in the String literal pool while "a"+"b" is in the String literal pool. Can someone explain that?
my guess is, because "a" +"b" is concatination of constant literals, the concatination is done by the compiler.
but since a, b are variable refrences thier value is not known till run time. as you said and as the above article pointed out, in this case a new String object is created in the heap.
Stephen Davies this:
be a well encapsulated person, don't expose your privates, unless you public void getWife()! is very funny (check the method again: you want a wife but you returned void. I think its better to use public void setWife(Woman theWoman) so your wife will not be exposed to the public)
love demgracy, knowledge demogracy, open source and Java - OCPJP 76%