I am creating an Array List of zip codes (29000 of them) and I am having trouble getting it to add the complete zipcodes to the arrayList. I think my problem is actually using the ArrayList because it is instantiated in another method.
Code Java:
public class ZipCodeDatabase { private ArrayList <ZipCode> list; public ZipCodeDatabase() { list = new ArrayList<ZipCode>(); } public void readZipCodeData (String filename) throws IOException { String info; Scanner fileReader; Scanner lineReader; fileReader = new Scanner(new File(filename)); while(fileReader.hasNext()) { info = fileReader.nextLine(); lineReader = new Scanner(info); lineReader.useDelimiter(","); int zip = lineReader.nextInt(); String city = lineReader.next(); String state = lineReader.next(); double longtitude = lineReader.nextDouble(); double latitude = lineReader.nextDouble(); ZipCode z = new ZipCode(zip, city, state, latitude, longtitude); list.add(z); } }
This uses the ZipCode method which is in another class and has the code
Code Java:
The class and method names are all given in the project. I'm a beginner Java student and this is my first time posting on these forums so don't hurt me too badly =P
Thanks,
PeskyToaster