Apex Code :
Map <id, Map <id,Account>> accountMap = new Map <id, Map <id,Account>> ();
for(Account acc : [select id,name from Account]) {
if(accountMap.containsKey(acc.id)) {
accountMap.get(acc.id).put(acc.id,acc);
} else {
accountMap.put(acc.id, new map <id, Account> {acc.id => acc});
}
}
system.debug('accountMapaccountMap'+accountMap);
Output:
Map <id, Map <id,Account>> accountMap = new Map <id, Map <id,Account>> ();
for(Account acc : [select id,name from Account]) {
if(accountMap.containsKey(acc.id)) {
accountMap.get(acc.id).put(acc.id,acc);
} else {
accountMap.put(acc.id, new map <id, Account> {acc.id => acc});
}
}
system.debug('accountMapaccountMap'+accountMap);
Output:
No comments:
Post a Comment