41.7k views
2 votes
How to use modulo operator in Java

1 Answer

3 votes

To use modulo in Java, you have to use the percent symbol %.

For instance,

int x = 2;

int y = 2;

System.out.println(x%y) will print 0 to the screen.

User Matt Cremeens
by
5.0k points