Java character compareTo() methodThe compareTo(character another character) method of character class is used to compare two objects numerically. SyntaxParameterThe above method requires only one parameter: The character that need to be compared. ReturnThe compare(char x, char y) method of character class returns : The value 0 if the given Character is equal to the argument Character. A value less than 0 if the given Character is numerically less than the Character argument A value greater than the given Character is numerically greater than the Character argument. Example 1Output: The first value 'g' is greater than the second value 'G'. Example 2Output: The first value 't' is greater than the second value 'G'. Example 3Output: The first value is greater than the second value The first and third value are equal Next TopicJava-character-digit-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