参考网址:https://www.cnblogs.com/baby123/p/12619872.html
创建长度为0的数组:
public static void main(String args[]){ Integer[] integer = new Integer[0]; System.out.println(integer.length); }
运行结果:0
做一下对比,创建一个为null的空数组
public static void main(String args[]){ Integer[] integer = null; System.out.println(integer.length); }
运行结果:
Exception in thread "main" java.lang.NullPointerException
at com.zyq.Test.main(Test.java:28)