java new line replacement

前端 未结 2 733
半阙折子戏
半阙折子戏 2021-01-13 09:42

I am wondering about why I don\'t get the expected result with this one:

String t = \"1302248663033   

        
2条回答
  •  野的像风
    2021-01-13 10:02

    Strings are immutable. String operations like replaceAll don't modify the instance you call it with, they return new String instances. The solution is to assign the modified string to your original variable.

    t = t.replaceAll("\n", "");
    

提交回复
热议问题