split拆分数组长度问题

时间:2023-03-08 18:19:56
package test;

public class test1_format {

    public static void main(String[] args) {
System.out.println("1&".split("&").length);//长度为1
System.out.println("1&1".split("&").length);//长度为2
System.out.println("1&&&".split("&").length);//长度为1
System.out.println("&1".split("&").length);//长度为2 }
}

split拆分数组长度问题