Java - char Unicode escape sequence

What is char Unicode escape sequence

A character literal can be expressed as a Unicode escape sequence as '\uxxxx'.

Sign Meaning
\u denotes the start of the Unicode escape sequence
xxxx represents exactly four hexadecimal digits. xxxx is the Unicode value for the character.

For example, the character 'A' has the Unicode value of 65. The value 65 in hexadecimal is 41. 'A' can be expressed in Unicode escape sequence as '\u0041'.

The following snippet of code assigns the same character 'A' to the char variables c1 and c2:

  
char c1 = 'A'; 
char c2 = '\u0041';  // Same as c2 = 'A' 

Demo

public class Main {
  public static void main(String[] args) {
    char c1 = 'A'; 
    char c2 = '\u0041';  // Same as c2 = 'A' 
    System.out.println(c1);/*  ww  w  .ja v  a 2 s .co m*/
    System.out.println(c2);
  }
}

Result