Language syntax

Numeric comparison and equality

Compares numeric operands following applicable promotion and produces a boolean. NaN makes ordered and equality tests false; inequality with NaN is true. Syntax shows alternative expressions, not standalone Java statements.

Formal Syntax & Structure

java syntaxjava
a < b; a <= b; a > b; a >= b; a == b; a != b

Working Example

Example Snippetjava
public class Main {    public static void main(String[] args) {        int stock = 8;        System.out.println(stock >= 8);        System.out.println(stock < 8);    }}
Java Reference