Answers for "java integer compareto"

2

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");  
          }  
    }  
}
Posted by: Guest on April-26-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language