Assuming that I'm running with an object like this like this:
static class fileHandler {
File fileToHandle;
ArrayList fileDetails;
fileHandler(File fileIn) {
fileToHandle = fileIn;
}
public void fileHandling() {
try {
Scanner reader = new Scanner(fileToHandle);
reader.useDelimiter(",");
while(reader.hasNext()) {
String s = reader.next();
fileDetails.add(s);
}
} catch (FileNotFoundException e) { System.err.println("File Not Found!"); }
}
}
How could I make "fileDetails" able to work inside my method?
fileDetails = new ArrayList<T>();fileDetailsfrom a concrete class, then it's far better to refer toListinstead. Makes your programs more flexible.