compareto java integer code example
Example: java integer compareto
public class IntegerCompareToExample {
public static void main(String[] args) {
// compares two Integer values numerically
Integer x = new Integer("90");
Integer y= new Integer("58");
int retResult = x.compareTo(y);
if(retResult > 0) {
System.out.println("x is greater than y");
} else if(retResult< 0) {
System.out.println("x is less than y");
} else {
System.out.println("x is equal to y");
}
}
}