Use Google stupid.
[url=http://forum.java.sun.com/thread.jspa?threadID=400783&messageID=1747511]String vs String Buffer[/url]
[url=http://forum.java.sun.com/thread.jspa?threadID=268514&messageID=1024221]Clarification of String Vs StringBuffer[/url]
[url=http://forum.java.sun.com/thread.jspa?threadID=675860]what is difference between string and stringbuffer?[/url]
> strings can;t be modified whereas stringbuffer can be.
import java.lang.reflect.*;
public class ImmutableStringDemo {
public static void main(String[] args) throws Exception {
String string = "foo";
System.out.println(string); // foo
new StringChanger().change(string);
System.out.println(string); // bar
}
}
class StringChanger {
public void change(String s) throws IllegalAccessException {
Field[] fields = s.getClass().getDeclaredFields();
for (Field f : fields) {
f.setAccessible(true);
if (f.getType() == char[].class) {
f.set(s, "bar".toCharArray());
}
}
}
}
QED.
~
> In other news, it has come to light that I can get by
> the Schlage industrial strength deadbolt in your
> front door with an Abrams tank... :)
Indeed. It would be silly of me to say you couldn't break into my house, despite the fact that I had taken reasonable precautions to prevent entry.
You can't turn my house into a fire-breathing pickle. But you can get in the front door if you try hard enough. :o)
~