Varargs with null parameters in Java
The following code simply uses a null reference as a varargs parameter. package currenttime; import java.util.Arrays; public class Main { private static void temp(String...str) { System.out.println(Arrays.asList(str)); } public static void main(String[] args) { temp(null,null); temp(null); } } The first call to the method temp(null, null); displays [null, null] means that str[0]=null and str[1]=null . but the later call to temp(null); causes the NullPointerException to be thrown which appears that the str itself is null . If it's type cast to String something like this temp((String)null); , it