What is the difference between modulus and divide symbol in java(% and /)? | Core Java Forum
H
Harika Posted on 13/04/2024

Y
Yogesh Chawla Replied on 15/04/2024

In Java, modulo operator(%) returns the remainder of a division operation 
while the divide operator returns the quotient of a division operation.
 
For example, if you divide 10 by 3, the result is 3 with a remainder of 1. 
The modulo operator would return 1, while the divide operator would return 3.
 
Please see this:
public class Class2 {
	public static void main(String[] args) {

		int a = 10;
		int b = 3;

		int remainder = a % b;
		int quotient = a / b;

		System.out.println("Remainder: " + remainder);
		System.out.println("Quotient: " + quotient);
	}

}