I am new to Apex. When I query Accounts in a List it shows all the records in a list without for loop. But When I query the same in set, it only shows One record. When I Check Size of the set, it displays actual size 100. enter image description here

set<Account> setAcc= new Set<Account>([select id from Account where Name Like 'Test%' limit 100 ]); 
system.debug('Debugging Set of Account'+ setAcc);//Shows only one record
System.debug('Debugging Set of Account Size'+ setAcc.size());// shows actual size i.e, 100

1 Answer 1


It seems this is a known issue, as explained in this post by Doug B, however, you can iterate through the set, and still get all records as expected.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .