8 件の回答
I was whacking my head on this!! Why you thought to give the class name "Contact"? Try the below code and please rename your class name.
public class contactclass {
public static void m(){
list<account> clist=[select id,name, (select Name from contacts) from account];
for(Account a: clist){
for(Contact c : a.Contacts){
System.debug('Account Name:: '+a.Name + ' ' + 'Contacts: ' + c.Name);
}
}
}
}