Just curious, but when I try to use this to reverse an array it always spits out some incoherent gibberish instead of the array reversed, such as [I@43256ea2
. Any ideas as to why it does this?
public class Fiddle {
public static void main(String[] args) {
int[] number = {1,2,3,4,5};
System.out.println(reverse(number));
}
public static int[] reverse(int[] a) {
int[] b = new int[a.length];
for (int i = 0; i < a.length; i++) {
b[a.length-1-i] = a[i];
}
return b;
}
}
Thanks for any ideas as to why this is happening (it's probably because I'm forgetting something though).