I\'m using Netbeans.
When I run the program below, I get this as output [I@de6ced
! How come?
import java.util.Arrays;
import java.util.Vector;
publ
[I@de6ced
can be broken down as:
- [
an array
- I
of integers
- de6ced
with this reference hash-code (which, in Sun Java, is basically the reference)
toString() for Object returns somethine like ClassName@HashCode, which is exactly what you're seeing happen here just with the (rather wierd) primitive-array classes.
The problem is that the wrong type is being inferred by the
method. Change your code to use Integer[]
instead of int[]
. This is a consequence of int being primitive, but int[] is an object.
You can see this directly:
System.out.println(Arrays.asList(new int[]{5}));
=> [[I@
some reference
System.out.println(Arrays.asList(new Integer[]{5}).get(0));
=> 5