I was told that strings in java can not be changed.What about the following code?
name="name";
name=name.replace('a', 'i');
Does not it changes name string?
Also, where is the implementation of the replace(); compareTo(); equals(); provided?
I am just using these functions here, but where actually are they implemented?
String.replace() returns a new String.
“name” is a reference to a String object, so it can be reassigned to point to name.replace(), but it will be pointing to a new object.
Here is the javadoc for String, where you can find out what all the methods do.