This course is currently a work in progress. Please join the waitlist to receive regular updates.
Integer variables in apex
What is an integer variable?
In Apex, you can use Integer variables to store numbers. Integers can hold only the whole numbers and they cannot hold decimal values.
Integer variables in Apex can be used to:
- Store a numeric value, e.g the number of orders.
- Run business rules certain times, e.g run a for loop x times
- Store constant values.
How to declare an Integer?
You can declare a integer using the Integer
data type and assign a value.
Loading...
In the above example:
- The keyword
Integer
is used to declare an Integer variable. - The variable name
numberOfOrders
is used to store an integer number. - The value
10
is assigned to the variablenumberOfOrders
.
Try It Yourself
Loading...