1. Questions
Public Static void aslist () { System.out.println (arrays.aslist (new string[] {"A", "B" }); System.out.println (Arrays.aslist (new integer[] {1, 2 })); System.out.println (Arrays.aslist (newint[] {1, 2 }));
System.out.println (Arrays.aslist (new object[] {new int[] {1, 2}});
System.out.println (arrays.aslist (new string[] {"A", "B"}, "C"));
The right way Apache Common Lang
System.out.println (Arrays.aslist (Arrayutils.toobject (new int[] {1, 2}));
}
[A, b]
[1, 2]
[[[Email protected]]
[[[Email protected]]
[[Ljava.lang.string;@2077d4de, C]
[1, 2]
Because the Java language specification calls for calling a method that is declared as Foo (t ... t), such as foo (new T[]{bar,baz}) is equivalent to a call such as Foo (Bar,baz). In the Arrays.aslist method, T is the parameter type,
So it must be an object type, but int is not, and int[] is. Arrays.aslist, as a negative case, tells us why we should be very careful when using the variable parameter design API for Java.
Reference:
Http://www.importnew.com/14996.html
Java arrays.aslist Issues