Replacing characters in Java

前端 未结 6 1226
囚心锁ツ
囚心锁ツ 2021-01-25 16:05

I tried to replace characters in String which works sometimes and does not work most of the time.

I tried the following:

String t = \"[javatag]\";
String         


        
6条回答
  •  离开以前
    2021-01-25 16:40

    Strings in Java are immutable, meaning you can't change them. Instead, do t1 = t1.replace("]", "");. This will assign the result of replace to t1.

提交回复
热议问题