java integer compareto

Solutions on MaxInterview for java integer compareto by the best coders in the world

showing results for - "java integer compareto"
Mats
24 Apr 2017
1public class IntegerCompareToExample {  
2    public static void main(String[] args) {      
3        // compares two Integer values numerically  
4          Integer x = new Integer("90");  
5          Integer y= new Integer("58");  
6          int retResult =  x.compareTo(y);        
7          if(retResult > 0) {  
8             System.out.println("x is greater than y");  
9          } else if(retResult< 0) {  
10             System.out.println("x is less than y");  
11          } else {  
12             System.out.println("x is equal to y");  
13          }  
14    }  
15}