Replacing characters in Java

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

    String.replace() returns a new string after replacing the required characters. Hence you need to do it in this way:

    String t = "[javatag]";
    t = t.replace("[","");
    t = t.replace("]","");
    

提交回复
热议问题