Apex Coding
What this topic covers
Write Apex using its core syntax, sObjects, primitive types, and control statements. Account for transaction behavior and governor limits, and guard against null values when working with records.
What does a null check do before calling a String method?
Checking for null before calling a String method such as toLowerCase prevents a null dereference error. Store the lowercase result in a separate variable so the original Contact records keep their values. Test the field in an if statement first, then call the method only when the field has a value.