This is my code
import java.util.*;
import java.io.*;
public class LSArrayApp{
public static void main(String[] args){
System.out.println(ReadFile());
}
public static String[] ReadFile(){
try{
File myFile =new File("fileName.txt");
Scanner scan = new Scanner(myFile);
System.out.println("Scanner creation succesful");
}
catch(FileNotFoundException e){
System.out.println("File not found");
}
String[] data = new String[2976];
int lineNumber = 0;
while (scan.hasNextLine()){
data[lineNumber] = scan.nextLine();
lineNumber++;
return data;
}
Everytime I run the code I get this error:
java: cannot find symbol symbol: variable scan location: class LSArrayApp
It seems that the scanner object is not instantiating and I can't figure out why.