Another Salesforce blog!!!

Salesforce, Apex

Apex Variables

Null Variables and Initial Values

If you declare a variable and don’t initialize it with a value, it will be null. In essence, null means the absence of a value. You can also assign null to any variable declared with a primitive type. For example, both of these statements result in a variable set to null:

A common pitfall is to assume that an uninitialized boolean variable is initialized to false by the system. This isn’t the case. Like all other variables, boolean variables are null if not assigned a value explicitly.


Leave a Reply

Your email address will not be published. Required fields are marked *