the error: java:51: variable latitude might not have been initialized
for all of the variables that are declared lines 11 through 19. I have no idea why this is. All of the dependencies compile correctly. Any ideas? Thank you.
import javafoundations.*;
import java.util.*;
import java.net.*;
import java.io.*;
public class Activity1 {
public static void main(String[] args) throws MalformedURLException, IOException {
URL url= new URL("http://depasquale-1.tcnj.edu/~depasqua/csc230/dataSources/zipcodes.txt");
Scanner sc= new Scanner(url.openStream());
ArraySet<Zipcode> zipcodes= new ArraySet<Zipcode>();
Zipcode zc;
String zip;
String latitude;
String longitude;
String city;
String state;
String county;
String type;
while(sc.hasNextLine()) {
Scanner sc2 = new Scanner(sc.nextLine()).useDelimiter(",");
if(sc2.hasNext()) {
zip=sc2.next();
if(sc2.hasNext()) {
latitude=sc2.next();
if(sc2.hasNext()) {
longitude=sc2.next();
if(sc2.hasNext()) {
city=sc2.next();
if(sc2.hasNext()) {
state=sc2.next();
if(sc2.hasNext()) {
county=sc2.next();
if(sc2.hasNext()) {
type=sc2.next();
}
}
}
}
}
}
if(!zip.equals("")&&!latitude.equals("")&&!longitude.equals("")&&!city.equals("")&&!state.equals("")&&!county.equals("")&&!type.equals("")) {
zc=new Zipcode(zip, latitude, longitude, city, state, county, type);
zipcodes.add(zc);
}
}
}
}
}

New Topic/Question
Reply



MultiQuote






|