So I'm trying to pass the variable numbers into the printArray method but I'm not completely sure how to do it. Obviously I'm not doing it right but could someone please point me in the correct direction? Thanks in advance.
import java.io.*;
import java.util.Scanner;
public class Paniagua_ArrayProcessing{
public static void main(String[] args) throws IOException{
int[] numbers = new int[4];
inputData();
printArray(numbers);
}
public static int[] inputData() throws IOException{
Scanner keyboard = new Scanner(System.in);
String input;
int lines;
System.out.println("Please enter a file name: ");
input = keyboard.nextLine();
File myfile = new File(input);
if (!myfile.exists()){
System.out.println("File not found.");
System.exit(0);
}
Scanner inputFile = new Scanner(myfile);
lines = inputFile.nextInt();
int[] numbers = new int[lines];
for (int i=0; i<lines; i++){
if (inputFile.hasNextInt()){
int moreLines = inputFile.nextInt();
numbers[i] = moreLines;
}
}
inputFile.close();
return numbers;
}
public static void printArray(int[] array){
System.out.println(array[3]);
}
}
main()throws an exception