I am writing a program that the main method asks the user for how many numbers they want in an array, then asks them to input that many numbers, and stores them in initialArray. In another method reverseTheArray, a NEW array is created that stores the elements of initialArray in reverse order. The method is called in main and prints the reversed array. No matter what input, the string "[I@33909752" is printed at the end. What is this and how do I get rid of it?
import java.util.Scanner;
public class Reverse {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("How many numbers do you want in your array?: ");
int num = scan.nextInt();
int[] initialArray = new int[num];
System.out.println("Please enter your numbers into the array: ");
for(int i=0; i<num; i++){
initialArray[i] = scan.nextInt();
}
System.out.println(reverseTheArray(initialArray));
}
public static int[] reverseTheArray (int[] initialArray){
int[] reversedArray = new int[initialArray.length];
for(int j=0; j<reversedArray.length; j++){
reversedArray[j] = initialArray[initialArray.length-1-j];
System.out.print(reversedArray[j]+" ");
}
return reversedArray;
}
}