
If(acc.size()>0)
{
code
}
Any suggestion...
4 个回答
You can also use a different syntax for initializing your List so you don't have to put try/catch blocks around things:
List<Account> acc = new List<Account>([select ......]);
This will initialize the List, and optionally populate it with records if the SELECT returns records. Otherwise, you have a valid List with no records and can safely check the size:
if (acc.size() > 0) { ....... }