import java.util.*;
public class Array {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String ArrayString[] = new String[9];
Map<String,Integer> mappa = new TreeMap<String,Integer>();
ArrayString[0] = "Filippo";
ArrayString[1] = null;
ArrayString[2] = "Marco";
ArrayString[3] = "Filippo";
ArrayString[4] = "Alberto";
ArrayString[5] = "Filippo";
for(int i = 0; i<ArrayString.length;i++){
if (ArrayString[i] != null){
Integer num = ContaNomi(ArrayString[i],ArrayString);
mappa.put(ArrayString[i], num);
//System.out.println(ArrayString[i]);
}
}
for(String value : mappa.keySet()){
System.out.println("Nome = " + value + " conti = " + mappa.get(value));
}
}
public static int ContaNomi(String Nome, String ArrayControllo[]){
int count = 0;
for(int i = 0;i<ArrayControllo.length;i++){
if (ArrayControllo[i] != null){
if( Nome.equals(ArrayControllo[i]))
count++;
}
}
return count;
}
}