In Java, the less-than operator (<
) is used to check if one value is less than another. It evaluates to true
if the left operand is less than the right operand; otherwise, it evaluates to false
.
Here's a simple example:
public class LessThanOperatorExample {
public static void main(String[] args) {
// Example values
int a = 5;
int b = 10;
// Check if a is less than b
if (a < b) {
System.out.println("a is less than b.");
} else {
System.out.println("a is not less than b.");
}
}
}
In this example, since a
is 5 and b
is 10, the condition a < b
is true
, and the program prints "a is less than b."