How to Use Modulus Operator in Java


In this example we will show you how to use modulus operator in Java.

Source Code

package com.beginner.examples;

public class ModulusOperator {
  public static void main(String[] args) {
    int a = 11;
    int b = 3;
    System.out.println(a % b); // use modulus operator
  }
}

Output:

2
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments