Java Integer compare() methodThe compare() method is a method of Integer class under java.lang package. This method compares two integer values numerically. It returns the result in integer equivalent value by comparing the two int method arguments. The value returned is identical to what would be returned by: Integer.valueOf(x).compareTo(Integer.valueOf(y)) SyntaxFollowing is the declaration of compare() method: Parameter:
Returns:This method will returns the following values: Exceptions:NA Compatibility Version:Java 1.7 and above Example 1Output: -1 0 1 Example 2Output: Enter the first numeric value: 55 Enter the second numeric value: 66 number1 is less than number2 Example 3Output: 1 0 -1 Next TopicJava-integer-compareto-method |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India