I am reading from a CSV file that contains data about Hills. I can read the data from the file, and have associated column headers with 6 fields. Currently my output prints like:
### County:Argyll and Bute
[48,Deinn a'Choin,Argyll and Bute,768.2,56.281081,-4.659943, 49,Feinn a'Choin,Argyll and Bute,768.5,56.281043,-4.659924, 50,Zeinn a'Choin,Argyll and Bute,768.7,56.281034,-4.659981]
### County:Stirling
[19,Beinn Each,Stirling,813.0,56.313957,-4.262199, 11,Creag Gharbh,Stirling,637.4,56.46677,-4.221506, 7,Meall Buidhe,Stirling,719.0,56.419004,-4.308645]
### County:Aberdeen
[19,Beinn Each,Aberdeen,813.0,56.313957,-4.262199, 11,Creag Gharbh,Aberdeen,637.4,56.46677,-4.221506, 7,Meall Buidhe,Aberdeen,719.0,56.419004,-4.308645]
But I am trying to get my output like:
### County:Argyll and Bute
NameOfHill#1 Height
NameOfHill#2 Height
NameOfHill#3 Height
### County:Stirling
NameOfHill#1 Height
NameOfHill#2 Height
NameOfHill#3 Height
### County:Aberdeen
NameOfHill#1 Height
NameOfHill#2 Height
NameOfHill#3 Height
So technically what I am trying to achieve is, select 3 values from my SET which are actually inside a map and only print out the name and height.
My code currently is:
for (int i = 0; i < 3; i++) {
System.out.println("### County:" + hillsByCounty.keySet().toArray()[i]);
System.out.println(hillsByCounty.get((hillsByCounty.keySet().toArray())[i]));
}
}
I believe i have to use another for loop, and somehow select only 3 values from the Set and use ".getName" and ".getHeight" in my final print statement
I had an idea of something along the lines
Set<Hill> getHills = hillsByCounty.get((hillsByCounty.keySet().toArray())[i]);
for (int j = 0 ; j < 3 ; j++){
//write to somehow code to pull the hill in pos j in this set
System.out.println(h.getName() + " " + h.getHeight());
}
}
}
But what im not sure about is, how to get these set values. My Map value is a set because my previous method initiates like:
public static Map<String, Set<Hill>> hillsByCounty(List<Hill> hills) {