Strings are immutable objects because once a String object is created, it can never be changed.
Again String class is marked final. Nobody can override the
behaviors of any of the String methods.
In Java, strings are objects. Just like other objects, you can create an instance of a
String with the new keyword, as follows:
String s = new String();
s = "abcdef";
String s = new String("abcdef");//Another constructor
Here the old String “abcdef” remains in memory but now ‘s’ refers to the new string “bhabani”.


No comments:

Post a Comment