Question: For Java. Using Hashmap, print the map and then print thecontinent that has the maximum number of countries and how manycountries are in that continent.
For Java. Using Hashmap, print the map and then print thecontinent that has the maximum number of countries and how manycountries are in that continent.
below is the code that I started.
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
/**
*
* @author abeer
*/
public class InClass06 {
/**
* @param args the commandline arguments
*/
public static void main(String[]args) {
// TODOcode application logic here
StringcsvFile = "./src/inclass06/Countries-Continents.csv";
Stringline = "";
StringcvsSplitBy = ",";
try(BufferedReader br = new BufferedReader(new FileReader(csvFile))){
while((line = br.readLine()) != null) {
//use comma as separator
String[]country = line.split(cvsSplitBy);
System.out.println(country[0]+"=> "+country[1]);
}
} catch(IOException e) {
e.printStackTrace();
}
}
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
