Java String trim() 方法
示例
从字符串的两侧删除空格
String myStr = " Hello World! ";
System.out.println(myStr);
System.out.println(myStr.trim());
定义和用法
The trim()
method removes whitespace from both ends of a string.
注意: 此方法不会更改原始字符串。
语法
public String trim()
参数
无。
技术详情
返回 | A String value, which is a copy of the string, without leading and trailing whitespace |
---|
❮ String Methods