1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
/* Modulus Operator Example This example shows how to use Java modulus operator (%). */ public class ModulusOperatorExample { public static void main(String[] args) { System.out.println("Java Modulus Operator example"); /* * Modulus operator returns reminder of the devision of * floating point or integer types. */ int i = 50; double d = 32; System.out.println("i mod 10 = " + i%10); System.out.println("d mod 10 = " + d%10); } } /* Output would be Java Modulus Operator example i mod 10 = 0 d mod 10 = 2.0 */ |
This is very useful in programming. If anyone does not understand this concept. Please research this more beacause trust me. Modulo is very helpful in a lot of asignments. (If understood fully).
Modulas operator is very important when it comes to java programming