Java Character compare() Method
The compare(char x, char y) method of Character class is used to compare two char values numerically. The final value returned is similar to what would be returned by:
The above method requires two parameters:
The compare(char x, char y) method of character class returns
Example 1Test it Now
First value is less than the second value.
Example 2Test it Now
Value 1 is greater than the value 2.
Example 3Test it Now
First and second values are equal. First value is less than the third value.