posted 18 years ago
Shiva, String immutable means if we create an objec of string with some value, the value is final we cannot change its value.
where as for string buffer, we can change the value present in string buffer object.
like StringBuffer b=new StringBuffer("kiran");
b.append("kumar");
now b will has kirankumar, we are able to change the content of
stringbuffer but where as for string, String str=new String("kiran");
str will always has content "kiran" even after this method call str.replace('i','r'); not only replace ,it is same for any other method .