Hi all, I have an assignment about treemapping that I'm kinda stuck with.

So, I initially have a treemap called world, containing name, region, gdp etc etc of each country. Obviously in this I can filter and print on any of these conditions.
However, I need to create a new treemap called regionList and pass each region from world into regionList, which I can do no problem and print out the regions no problem.

Thing is I need to then count the number of countries in each region and then print out region then number.
Would greatly appreciate pointers on an efficient way to pass countries as keys and regions as values then print them.

Here's what I have so far,

import java.util.TreeMap;
import java.io.BufferedReader;
import java.io.FileReader;

class Country{
public String name;
public String region;
public int area;
public long pop;
public long gdp;
public Country(String name,String region, int area, long pop, long gdp){
this.name=name;
this.region=region;
this.area = area;
this.pop=pop;
this.gdp=gdp;
}
public String toString(){
return "(name:'"+name+"',region:'"+region+"',area:"+area+ "sqkm,pop:"+pop+",gdp:"+gdp+")";
}
}


public class Reader{
static void doStuff(TreeMap<String,Country> world)
{
TreeMap<String,Integer> regionList
= new TreeMap<String,Integer>();

for(Country s:world.values()){
if(!regionList.containsValue(s.region))
regionList.put(s.region, 0);
}

for(String s:regionList.keySet())
System.out.printf("%-35s%3d\n",s,regionList.get(s));
}

public static void main(String [] argv)throws Exception{
TreeMap<String,Country> world = new TreeMap<String,Country>();
BufferedReader fh =
new BufferedReader(new FileReader("bbc.txt"));
String line;
while ((line=fh.readLine())!=null){
String [] wrds = line.split("\t");
world.put(wrds[0],new Country(wrds[0], wrds[1],Integer.parseInt(wrds[2]),
Long.parseLong(wrds[3]),Long.parseLong(wrds[4])));
}
doStuff(world);
}
}