Language syntax

Remainder operator %

For integral values, returns the remainder after truncating division. It follows the dividend sign, and a zero divisor throws ArithmeticException. Floating-point remainder has different zero-divisor behavior.

Formal Syntax & Structure

java syntaxjava
left % right

Working Example

Example Snippetjava
public class Main {    public static void main(String[] args) {        System.out.println(23 % 5);        System.out.println(-23 % 5);    }}
Java Reference