Почему int [] a = new int [0]; позволил?
Есть ли причина, почему
int[] myArray = new int[0];
компилирует?
Есть ли смысл в таком выражении?
myArray[0] = 1;
дает.java.lang.ArrayIndexOutOfBoundsException
if (myArray == null) {
System.out.println("myArray is null.");
} else {
System.out.println("myArray is not null.");
}
дает.myArray is not null.
Так что я могу'не вижу причины, почемуint[] myArray = new int[0]
должно быть предпочтительнее, чемmyArray = null;