I am quite confused as to how Java calculates the length of the varargs:
static void hello(Integer... x){
System.out.println(x.length);
}
public static void hi(){
hello();
}
This prints a 0.
When I pass :
static void hello(Integer... x){
System.out.println(x.length);
}
public static void hi(){
hello(null);
}
This throws a Null pointer exception.
And
static void hello(Integer... x){
System.out.println(x.length);
}
public static void hi(){
Integer[] xIntegers= new Integer[44];
hello(xIntegers);
}
This prints 44.
Can someone please help me understand?