对于Map的应用 水题
import java.io.*;
import java.util.*;
public class Main{
public static void main(String[] args) throws IOException{
StreamTokenizer cin = new StreamTokenizer( new BufferedReader( new InputStreamReader(System.in) ) );
PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));
Map<String,Integer> ma = new HashMap<String,Integer>();
while( cin.nextToken()!=StreamTokenizer.TT_EOF ){
ma.clear();
int n=(int)cin.nval;
if(n==0) break;
for(int i=0;i<n;i++){
cin.nextToken();
String color = cin.sval;
//System.out.println(color);
if( ma.get(color) == null ){
//System.out.println(color+" is not in map!");
ma.put(color,1);
} else {
ma.put(color,ma.get(color)+1);
}
}
Iterator itec = ma.entrySet().iterator();
int max=-1;
String s=null;
while(itec.hasNext()){
Map.Entry<String,Integer> me = (Map.Entry<String,Integer>)itec.next();
if(max < me.getValue() ){
max=me.getValue();
s=me.getKey();
}
}
pw.println(s);
pw.flush();
}
pw.close();
}
}