This content has been marked as final. Show 2 replies
Inside the println, you are printing the result of the replace.
Outside the println, you are calculating the replace, discarding the result which is returned and printing the original value.
What you may have indended was
This question doesn't have anything to do with IO. Perhaps the "New to Java" forum is a better place next time. ;)
String z = "12345"; z = z.replace("5", "6"); System.out.println(z); //o/p is "12346".