very first quesiton here: I did a code of swapping an array:
class Test {
public static void main(String[] args){
int[] arr = {2,3,8,4,1};
reverse (arr);
System.out.println(reverse (arr));
}
public static int[] reverse (int[] arr) {
int i=0, j=arr.length - 1;
while(i<j){
int temp = arr[i];
arr[i]=arr[j];
arr[j]=temp;
i++;
j--;
}
return arr;
}
}
the printout are supposed to be {1,4,8,3,2} but it shows "[I@2d98a335" after run, not sure which step is wrong.