Java trim() method: remove the spaces before and after the string
•
Java
trim()
Example
public static void main(String[] args){
String strCom = "JAVA编程词典"; //定义字符串
String str = strCom.trim(); //去除字符串前后的空格
System.out.println("未去除前后空格的字符串:"+strCom);
System.out.println("去除前后空格后的字符串:"+str);
}
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码
