Java Data Type Tutorial - Java Character.compare(char x, char y)








Syntax

Character.compare(char x, char y) has the following syntax.

public static int compare(char x,  char y)

Example

In the following code shows how to use Character.compare(char x, char y) method.

public class Main {

   public static void main(String[] args) {

      System.out.println( Character.compare('a', 'b') );
   }
}

The code above generates the following result.