Java: Modulo
What is Modulo?
Modulo is a math symbol represented with % sign. When two numbers are divided, modulo is the remainder of the two numbers.
How to use Modulo
// This class divides two numbers and prints out the remainder
public class modulo {
public static void main(String[] args) {
int remainder = 10 % 4; // The variable remainder is the remainder of 10 / 4
System.out.println( remainder ); //Prints out 2 because 2 is the remainder of 10 / 4
}
}
Leave a comment
You must be logged in to post a comment.