java中的string字符串中的trim函数的作用

去掉字符串首尾空格  防止不必要的空格导致错误
public class test{
public static void main(String[] args) {
String str = " abc ";
System.out.println(str.length());//输出6
System.out.println(str.trim().length());//输出3
}
}
原文地址:https://www.cnblogs.com/tanglc/p/3350576.html