I am trying use String.replace(oldChar,newChar) , but this returns a Changed string. Example:
String tempString= "abc is very easy";
String replacedString=tempString.replace("very","not");
System.out.println("replacedString is "+replacedString);
System.out.println("tempString is "+tempString);
OUTPUT :
replacedString is abc is not easy
tempString is abc is very easy
So my question is there any way to replace string without storing it in another String.
I want output of
String tempString= "abc is very easy";
tempString.replace("very","not");
System.out.println("tempString is "+tempString);
as
tempString is abc is not easy.
by using replace function.