# 不保留尾部空字符串
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)); } }