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.
There is no way the code can work. hello and java without quotes are treated as variables. And since they are not declared before Compiler flags an error. Use of intern on a string object makes puts that it in the common pool of strings. that is String s1 = new String("a"); String s2 = new String("a"); In this case two objects created above are different, but if you use intern() above, then two objects share the same space and hence are same. Regards Gunjan
Is there more to the program that you forgot to mention? Did you perhaps define hello and java somewhere?
"I'm not back." - Bill Harding, Twister
Joined: Oct 29, 2002
Sorry , they are variables which I had declared. I am sorry for this!!
Joined: Jan 30, 2000
And did you perhaps give the variables values? Like <code><pre> String hello = "hello"; String java = "java";</pre></code> If so, then there's really no difference between <code><pre> System.out.println(hello + java);</pre></code> and <code><pre> System.out.println("hello" + "java");</pre></code> Should there be? It would be easier to answer your questions if you provided more information about what you're talking about, and why it confuses you. As for intern(), it's defined in String.intern().
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com