These are the methods I use to check if a field is empty:

p.Call_Summary__c != null 

And these are the methods to check that a list isn't empty:

CClist != null 

Do you recommend on anything else? What's the difference between 'isEmpty' to '!=null'?

Thank you


For lists the difference is that

CClist != null

Checks if you declared the list. You can't use isEmpty() on a non-declared list - it'll throw you an Exception.


Will always return true(if list is declared), because it shows whether or not list has elements and will never return null. It always returns either true or false. In order to check if list has elements you need to check both:

if (CClist != null && !CClist.isEmpty())


if (CClist != null && !CCList.size() >0)
  • Is there a difference between '!CClist.isEmpty()' to 'CCList.size() >0' ? – Json Nov 30 '16 at 8:25
  • @Barracks no difference at all. – EvAzi Nov 30 '16 at 9:01

isEmpty returns true or false so in your example if it was empty or not it would evaluate to true.


string fields you can use string.isBlank or string.isNotBlank

For lists and sets you can use

set.isEmpty() which returns true if it is or false if it is not

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.