hu996996 2017-08-09 06:01 采纳率: 0%
浏览 916

String.trim()源码释义

public String trim() {
int len = value.length;
int st = 0;
char[] val = value; /* avoid getfield opcode */

   while ((st < len) && (val[st] <= ' ')) {
        st++;
    }
    while ((st < len) && (val[len - 1] <= ' ')) {
        len--;
    }
    return ((st > 0) || (len < value.length)) ? substring(st, len) : this;
}

    while的条件中字符的Unicode码小于等于空字符的Unicode码32(\U0020),就 
    表示空字符了,这怎么理解?
  • 写回答

4条回答 默认 最新

  • a0984 2017-08-09 06:20
    关注

    去掉字符串前后的" "

    评论

报告相同问题?