Hi i have a java class called City and in this class i have this.
public class City {
/**
* read the file and make 10 objects
*
*/
private String name;
private double population;
public City(String name, double population) {
super();
this.name = name;
this.population = population;
}
public String getName() {
return name;
}
public double getPopulation() {
return population;
}
}
I am then making another class called CityTester that will test the class and i want to read a file that i have that has 10 different names and populations of city's, with each name/pop on one line each. i am then reading the file and making 10 different objects from the 10 different names. what i am having trouble with is i want to compare these 10 City objects and put them from smallest to largest(based on population) and then print them out. i know that you cant use Arrays.sort since it will only compare the one City array object. so does anyone have any suggestions on how i should go on reading/comparing the file?
thank you :)