Integers are a fundamental data type in Apex used to represent whole numbers (numbers without a fractional component). They can be positive, negative, or zero.
// Declaring and initializing an Integer
Integer numberOfStudents = 25;
// Performing arithmetic with Integers
Integer score1 = 80;
Integer score2 = 95;
Integer totalScore = score1 + score2;
System.debug('Total score: ' + totalScore); // Outputs: Total score: 175
Sign up to track your progress, earn points, and compete with others. Your solutions will be saved automatically.
Create account