String str="India's";
str.replaceAll("'", "");
The above code in my opinion should replace all inverted single commas with nothing in the string.
But the in the output nothing changes.
Can anyone figure out what am I doing wrong?
Thanks
String str="India's";
str.replaceAll("'", "");
The above code in my opinion should replace all inverted single commas with nothing in the string.
But the in the output nothing changes.
Can anyone figure out what am I doing wrong?
Thanks
 
    
    String is immutable, assign it to the same reference
str = str.replaceAll("'", "");
 
    
    String is an immutable class, any change to an object of this class will result in a new object created. Method replaceAll is returning the updated String object. so you should do something like this:
str = str.replaceAll("'","");
