I'm self learning programming and practicing my skills as I move forward. I've been consistently encountering a bug, and fixing it by trial and error but haven't really learned my actual mistake so far, if it is syntax or logic and how to avoid encountering it in the future.
my problem is as follows: I build a method that uses certain data or inputs certain data, and after the program successfully runs through the method and exits it, the data that was created/sorted/input within the method is lost for the rest of the program. If anyone would help me understand what I am missing every time, I'd really appreciate it.
public static void EnterArray(double[] array, int arraySize) {
Scanner input = new Scanner(System.in);
System.out.println("Array size: ");
arraySize = input.nextInt();
array = new double[arraySize];
for(int i=0; i<arraySize; i++) {
array[i]= input.nextInt();
}
input.close();
}
This method will create an array from the users input. Within the method, the data is stored correctly, but once it exits the method, the array created is gone. I would like to use that array within my next steps and methods in my program
Thank you!