Why don't I see the values of the integers in a returned array in Java? -
here main method:
public static void main(string[] args) { int[] myarray = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; (int = 0; < myarray.length; i++) { system.out.println(myarray[i]); } int[] sortedarray = insertionsort.sorter(myarray); (int = 0; < sortedarray.length; i++) { system.out.println(sortedarray); } }
and here insertionsort.sorter looks like:
public static int[] sorter(int[] a) { return a; }
and output:
1 2 3 4 5 6 7 8 9 10 [i@7000a32b [i@7000a32b [i@7000a32b [i@7000a32b [i@7000a32b [i@7000a32b [i@7000a32b [i@7000a32b [i@7000a32b [i@7000a32b
so missing?
for (int = 0; < sortedarray.length; i++) { system.out.println(sortedarray); }
what missing array index:
for (int = 0; < sortedarray.length; i++) { system.out.println(sortedarray[i]); // note [i] }
or (using for-each loop):
for (int i: sortedarray){ system.out.println(i); }
what doing print whole array (which not pretty in java).
Comments
Post a Comment