1 public class TestMapController{ 2 3 public map<string,integer> data {get;set;} 4 5 public TestMapController(){ 6 data = new map<string,integer>(); 7 for(Account acc: [Select Id, Name, (Select Id, Name, Email from Contacts), Phone from Account]){ 8 integer count = data.get(acc.name); 9 if(count != null) 10 count++; 11 else 12 count = 1; 13 data.put(acc.name, count); 14 } 15 } 16 }