Replacing characters in Java

前端 未结 6 1260
囚心锁ツ
囚心锁ツ 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:50

    Strings are immutable so

    t.replace(....);
    

    does nothing

    you need to assign the output to some variable like

    t = t.replace(....);
    

提交回复
热议问题