Hint: input:this is String this is String
output:[this 2 is 2 String 2]
import java.util.*;
public class FC
{
public static void main(String[] args)
{
HashMap hm=new HashMap();
for(String s:args)
{
if(hm.get(s)!=null)
{
int v=hm.get(s);
v=v+1;
hm.put(s,v);
}
else
hm.put(s,1);
}
System.out.println(hm);
}
}
No comments:
Post a Comment