Community
Participate
Working Groups
Hi. When passing "null" into a varargs method foo(Object... o) at the *first* position such as foo(null,oneObject,anotherObject), what you retrieve inside the method foo is not an array with array[0]==null, array[1]==oneObject and array[2] ==anotherObject, but simply "null" as the full array value. When I pass in foo(new Object[]{null,oneObject,anotherObject}) it works just fine. Also there is apparently no problem, when null occurs at any other position but the first, such as foo(oneObject,null,anotherObject).
Could you please provide the build id?
This is I20050219-1500. Here my test case: ____ public class T { /** * @param args */ public static void main(String[] args) { foo("abc",null); foo(new Object[]{null,"abc"}); foo(null,"abc"); } static void foo(Object... o) { System.out.println(o[1]); } } ____ This outputs: null abc Exception in thread "main" java.lang.NullPointerException at T.foo(T.java:16) at T.main(T.java:11) (because o is null in the third case)
With latest, I get: null abc abc Closing as WORKSFORME.
Reopen to close as duplicate.
*** This bug has been marked as a duplicate of 87042 ***