static void populate(Map m)
{
for(int i=0;i<10;i++)
{
m.put(i,i);
At this line you are putting m.put(Integer,Integer), while map needs to put(Integer, String)
}
}
So when you call this line
System.out.println(map.get(1)+sap.get(1));
map.get(1); it will return Integer but JVM will try to cast it to String, that is called ClassCastException.