Compile error in CVOTE problem

the following code is compiling and running fine in my system for the problem CVOTE. however, it fails to compile in codeshef. Can someone please explain why??

import java.util.*;

public class Main {

public static void main (String[] args){
    Scanner scn = new Scanner(System.in);
    int n=scn.nextInt();
    int m=scn.nextInt();
    
    HashMap hm1 = new HashMap();        //chef and votes
    HashMap hm2 = new HashMap();        // country and votes
    HashMap hm3 = new HashMap();        // input- chef and country
    
    for(int i=0;i<n;i++){
        String key = scn.next();
        String value=scn.next();
        String temp=scn.nextLine();
        hm3.put(key, value);
    }
    Set set = hm3.keySet();
    Iterator hmitr = set.iterator();
    
    while(hmitr.hasNext()){
        Object key1= hmitr.next();
        Object value1= hm3.get(key1);
        hm1.put(key1,0);
        hm2.put(value1,0);
    }
    
   for(int i=0;i<m;i++){
       String candidate= scn.nextLine();
       hm1.put(candidate,(int)hm1.get(candidate)+1);
       hm2.put(hm3.get(candidate),(int) hm2.get(hm3.get(candidate))+1);
   }
   
   String bestcountry="zzzzzzzzzz";
   int maxvotes=0;
   set=hm2.keySet();
   hmitr=set.iterator();
   while(hmitr.hasNext()){
       String country= (String)hmitr.next();
       if((int)hm2.get(country)>maxvotes){
           maxvotes=(int)hm2.get(country);
           bestcountry=country;
       }
       if((int)hm2.get(country)==maxvotes){
           bestcountry= (bestcountry.compareTo(country))<0 ?bestcountry:country;
       }
   }
   System.out.println(bestcountry);
   
   
   
   
   String bestcandidate="zzzzzzzzzz";
   maxvotes=0;
   set=hm1.keySet();
   hmitr=set.iterator();
   while(hmitr.hasNext()){
       String candidate= (String)hmitr.next();
       if((int)hm1.get(candidate)>maxvotes){
           maxvotes=(int)hm1.get(candidate);
           bestcandidate=candidate;
       }
       if((int)hm1.get(candidate)==maxvotes){
           bestcandidate= (bestcandidate.compareTo(candidate))<0 ?bestcandidate:candidate;
       }
   }
   System.out.println(bestcandidate);
    
}

}

Error shown by codeshef-

Main.java:32: inconvertible types found : java.lang.Object required: int hm1.put(candidate,(int)hm1.get(candidate)+1); ^ Main.java:32: operator + cannot be applied to ,int hm1.put(candidate,(int)hm1.get(candidate)+1); ^ Main.java:33: inconvertible types found : java.lang.Object required: int hm2.put(hm3.get(candidate),(int) hm2.get(hm3.get(candidate))+1); ^ Main.java:33: operator + cannot be applied to ,int hm2.put(hm3.get(candidate),(int) hm2.get(hm3.get(candidate))+1); ^ Main.java:42: inconvertible types found : java.lang.Object required: int if((int)hm2.get(country)>maxvotes){ ^ Main.java:43: inconvertible types found : java.lang.Object required: int maxvotes=(int)hm2.get(country); ^ Main.java:46: inconvertible types found : java.lang.Object required: int if((int)hm2.get(country)==maxvotes){ ^ Main.java:61: inconvertible types found : java.lang.Object required: int if((int)hm1.get(candidate)>maxvotes){ ^ Main.java:62: inconvertible types found : java.lang.Object required: int maxvotes=(int)hm1.get(candidate); ^ Main.java:65: inconvertible types found : java.lang.Object required: int if((int)hm1.get(candidate)==maxvotes){ ^ Note: Main.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 10 errors

Thanx in advance!!!

both functions get() and put() have return type.

public V put(K key,V value)
Associates the specified value with the specified key in this map. If the map previously contained a mapping for the key, the old value is replaced…
in line 32 you used hm1.put(candidate,(int)hm1.get(candidate)+1) here this will return an integer value and there is no new variable to handle it so a new variable should be used to handle it.

public V get(Object key) Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.
again when you used get here in your mathod argument should be integer type but candidate is string type variable which can not be converted to integer type implicitly…

finally, igot the solution… apparently typecasting through (int)Object is supported from java1.7. codeshef uses java 1.6, where we have 2 use (Integer)Object to typecast. anyways thanx!! :smiley: