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.
First, a bit of business: you may not have read our naming policy on the way in. It requires that you use a full, real (sounding) first and last name for your display name. Joke names and "handles" aren't acceptable here. You can change your display name here. Thanks!
Now, as to your question: immutablity is not a promise of magic, nor any special internal property of an object. Immutability just means that an object's accessible interfaces provide no way to change its state. Reflection does an end run around that. In the case where security is important, like when the JVM is running downloaded code (an applet container, a RMI application) then the security manager can be switched on, and it can block attempts to use reflection in this way. But in a normal application, your code has full access to reflection -- but of course, this is a bad idea, because an awful lot of code assumes String won't change, and will break if that turns out to be false.
Without the parenthesis it prints out the result of "before i==i2 ?:Ajay" == "Ajay", which is always false.
At first, I thought this was the reason why you were getting these strange results. But even with this fix, you get the same results. The two Strings are different instances, yet both char arrays are changed...very strange. It must have something to do with how Java interns Strings.