Question: Getting error when trying to run my code, please help !! when my friend did it he did not get an error and we have
Getting error when trying to run my code, please help !! when my friend did it he did not get an error and we have the same code...
package zipcode;
import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner;
public class ZipCodeDriver { public static void main(String[] args) { //file contening the data that will be loaded into the array String filename = "zipcodes.txt";
// Load data try { Scanner infile = new Scanner(new File(filename)); ZipCodeList1 myZipCodelist = new ZipCodeList1(); ZipCode c; while(infile.hasNext()){ c = new ZipCode(); c.setZipcode(infile.nextLine()); c.setTown(infile.nextLine()); c.setState(infile.nextLine()); myZipCodelist.add(c); } infile.close(); System.out.println("Loaded " + myZipCodelist.getSize() + " zip codes"); // Search for the data String search = ""; Scanner keyboard = new Scanner(System.in); while(true){ System.out.print("Hello, please enter zip code to search (type done to stop): "); search = keyboard.next(); if(search.equalsIgnoreCase("done")) break; c = myZipCodelist.find(search); if(c == null) System.out.println("Sorry but the zip code entered was not found"); else System.out.println("Found " + search + ": [" + c + "]"); } // In case we don''t find the data } catch (FileNotFoundException e) { System.out.println(e.getMessage()); } }
} Exception in thread "main" java.lang.UnsupportedOperationException: Not supported yet. at zipcode.ZipCodeList1.add(ZipCodeList1.java:15) at zipcode.ZipCodeDriver.main(ZipCodeDriver.java:33) C:\Users\camil\AppData\Local\NetBeans\Cache\8.1\executor-snippets un.xml:53: Java returned: 1 BUILD FAILED (total time: 0 seconds)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
