Skip to content

Instantly share code, notes, and snippets.

@peschwa
Created March 10, 2015 12:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peschwa/18a71ad844937594ec12 to your computer and use it in GitHub Desktop.
Save peschwa/18a71ad844937594ec12 to your computer and use it in GitHub Desktop.
[psch@mnpc tmp]$ cat VarArgs.java
public class VarArgs {
public static void main(String... args) {
int[] arg1 = new int[2];
String[] arg2 = new String[2];
Object[] they = makeArray(arg1, arg2);
for(int i = 0; i < they.length; ++i) {
System.out.println("idx: " + i + "\tclass: " + they[i].getClass());
}
}
public static Object[] makeArray(Object... they) {
return they;
}
}
[psch@mnpc tmp]$ java VarArgs
idx: 0 class: class [I
idx: 1 class: class [Ljava.lang.String;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment