Hello Trailblazers,
In this post, I'm sharing the code snippet for Coding with Confidence: The Fun Way to Learn Salesforce Apex tutorial series part 2 and 3 below:
// * Variables & Data Types in Apex
/*
? What is a variable?
* A variable is simply a named storage/memory location that contains a value. In apex, all variables have a "data type".
! Each variable is by default initialized to null
? What is a Data Type?
* Data type is a keyword associated with a variable. It basically represents the type of data which that variable will store.
* List of primitive data types:
* 1. Boolean
* 2. Integer
* 3. Decimal
* 4. Double
* 5. Long
* 6. Date
* 7. Datetime
* 8. Time
* 9. Id
* 10. String
* 11. Object
* 12. Blob
* These are the OOTB or fundamental data types available in apex programming language. Let's talk about each one of them in detail:
? What is a Boolean data type?
* A variable of Boolean data type can store only one of these two values:
* 1. True
* 2. False
* Example of Boolean data type:
*/
/*
one
two
three
*/
// comment
// * In order to declare a variable, we follow the format: <Data Type><space><Variable name><;>
Boolean isQualified;
System.debug('Value of isQualified boolean variable is: ' + isQualified);
isQualified = false; // * Equals (=) means Assignment
System.debug('Value of isQualified boolean variable is: ' + isQualified);
isQualified = true;
System.debug('Value of isQualified boolean variable is: ' + isQualified);
// isQualified = 123;
YouTube Tutorials
You can check out the tutorials below as well:
Building Blocks of Apex: Variables & Data Types Explained Simply - Salesforce Apex Tutorial Part 2
Apex Gotchas! Common Variable Errors (and Writing Comments) - Salesforce Apex Tutorial Part 3
Check out the tutorials and let me know your feedback in the comments down below.
Happy Trailblazing!!