For the following code:
1. public class X {
2. public static void main (
String[]args) {
3. string s = new string (�Hello�);
4. modify(s);
5. System.out.printIn(s);
6. }
7.
8. public static void modify (String s) {
9. s += �world!�;
10. }
11. }
The program runs and prints �Hello�.
But for the following code:
public class
test {
public static void main (String[]args) {
StringBuffer s = new StringBuffer ("Hello");
modify(s);
System.out.println(s);
}
public static void modify (StringBuffer s) {
s.append("world!");
}
}
The program runs and prints �Hello world!�.
Why for StringBuffer it is getting updated and not for String??
pls help
regards,
gitesh