I have made a programme to count the number of words using HashMap.Here it is-:
import java.util.*;
class Count{
public static void main(String args[]){
Scanner s=new Scanner(System.in);
String in=s.nextLine();
HashMap hm=new HashMap();
String sh[]=in.split(" ");
for(int i=0;i<sh.length;i++){
String key=sh[i];
if(sh[i].length() > 1){
if(hm .get(key)==null){
hm.put(key,i);
}
else{
int value=new Integer(hm.get(key).intValue());
value++;
hm.put(key,value);
}
}
}
System.out.println(hm);
}
}
But in this programme I am getting error that .intValue() symbol not found as I am using jdk 1.6 a feature of autoboxing and unboxing is added so I guess that is the problem.I want to calculate the count so Please give me the solution.