Created
March 10, 2015 12:50
-
-
Save peschwa/18a71ad844937594ec12 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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