Skip to content

Instantly share code, notes, and snippets.

@ALRubinger
Last active August 29, 2015 14:03
Show Gist options
  • Save ALRubinger/e14a3f905561f9015575 to your computer and use it in GitHub Desktop.
Save ALRubinger/e14a3f905561f9015575 to your computer and use it in GitHub Desktop.
Java Puzzler
public class NullVarArgs {
public static void main(String... args) {
// 1
exec(null);
// 2
exec((String) null);
// 3
final String s = null;
exec(s);
}
private static void exec(String... args) {
System.out.println(args);
}
}
@qmx
Copy link

qmx commented Jun 26, 2014

Warning:(8, 14) java: non-varargs call of varargs method with inexact argument type for last parameter;
cast to java.lang.String for a varargs call
cast to java.lang.String[] for a non-varargs call and to suppress this warning

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment