# 不保留尾部空字符串

public class QQ {
    public static void main(String[] args) {
        String str = "a,b,c,d,";
        String[] strArr = str.split(",");
        System.out.println(JSON.toJSON(strArr));
    }
}

# 保留尾部空字符串

public class QQ {
    public static void main(String[] args) {
        String str = "a,b,c,d,";
        String[] strArr = str.split(",", -1);
        System.out.println(JSON.toJSON(strArr));
    }
}

 

相关文章:

  • 2021-07-10
  • 2021-09-29
  • 2021-09-04
  • 2022-03-09
  • 2021-05-17
  • 2022-12-23
  • 2021-06-26
猜你喜欢
  • 2021-11-26
  • 2022-12-23
  • 2022-01-12
  • 2022-12-23
  • 2021-08-06
  • 2021-08-10
  • 2021-11-22
相关资源
相似解决方案