Code:
package isbnchecker; import java.io.FileNotFoundException; import java.io.FileReader; import java.util.ArrayList; import java.util.Scanner; import java.util.logging.Level; import java.util.logging.Logger; public class ISBNReader { private ISBN isbn = new ISBN(); private ArrayList<String> inISBN = new ArrayList<String>(); private String fileName = ""; private String next = ""; public ISBNReader(){ this.isbn = null; this.inISBN = null; } public void setFileName(String fileName){ this.fileName = fileName; } public String getFileName(){ return fileName; } public void setISBNNumbers(){ try{ FileReader fr = new FileReader(fileName); Scanner in = new Scanner(fr); while(in.hasNext()) [COLOR="Red"] [B]inISBN.add(in.next()); [/B][/COLOR] } catch(FileNotFoundException ex){ Logger.getLogger(ISBNReader.class.getName()).log(Level.SEVERE, null, ex); } } public ArrayList<String> getISBNNumbers(){ return inISBN; } }
at isbnchecker.ISBNReader.setISBNNumbers(ISBNReader.java:43)
at isbnchecker.Main.main(Main.java:34)
Java Result: 1
Hey everyone, I am currently working on this programming assignment for my computer science class and am having some trouble with an arraylist in the code above (the line in red). I can't seem to figure out what is causing the error I keep receiving. Any suggestions?
Thanks!
Comment