how to replace colon (:) in a String

I have a requirement like replace the colon ( in a string. I tried with the following code: /** String str = "abc ef:ghi"; str.replaceAll(":","_"); system.out.println(str); **/ But the output i am getting the string with unchanged.

output ---------- abc ef:ghi

Could you please let me know why i am not able to replace the colon? Also point me to the correct code that satisfy my requirement.

You wrote: -------------------------------------------------------------

Hi Team,

I have a requirement like replace the colon ( in a string. I tried with the following code: /** String str = "abc ef:ghi"; str.replaceAll(":","_"); system.out.println(str); **/ But the output i am getting the string with unchanged.

output ---------- abc ef:ghi

Could you please let me know why i am not able to replace the colon? Also point me to the correct code that satisfy my requirement.

Thanks.

---------------------------------------------------------------

the replaceAll method will return a String which is not assigned to any variable. Because of this you are not seeing the change. Replace your code