Modulus Operators In Java Example

Chapter: Operators Last Updated: 15-07-2016 14:03:43 UTC

Program:

            /* ............... START ............... */
                
public class JavaModulusOperatorExample {

	public static void main(String[] args) {
		System.out.println("Java Modulus Operator example");
		int i = 50;
		double d = 32;

		System.out.println("i mod 10 = " + i % 10);
		System.out.println("d mod 10 = " + d % 10);
	}

}
                /* ............... END ............... */
        

Output

Java Modulus Operator example
i mod 10 = 0
d mod 10 = 2.0

Notes:

  • Modulus operator returns reminder of the division of floating point or integer types.
  • For example, 8 % 3 evaluates to 2 because 8 divided by 3 has a remainder of 2.

Tags

Modulus Operators, Java

Similar Programs Chapter Last Updated
Java Left Shift Operator Operators 04-09-2018
Java Addition Operator Operators 18-05-2017
Java Right Shift Operator Operators 13-12-2016
Prefix Operator In Java Example Operators 19-06-2016
Logical Operators In Java Example Operators 17-06-2016
Operator Precedence In Java Examples Operators 17-06-2016
Ternary Operators In Java Example Operators 15-07-2016
Relational Operators In Java Example Operators 11-06-2016
Increment And Decrement In Java Example Operators 15-07-2016
Boolean Operator In Java Example Operators 15-07-2016
Bitwise Operator In Java Example Operators 16-06-2017
Assignment Operation In Java Example Operators 06-04-2016
Arithmetic Operation In Java Example Operators 11-06-2016

1