char c = 'A'; int i = c; // i contains the Unicode code of the character 'A' System.out.println(i); // prints 65
int i = 65; // Unicode code of the character 'A' char c = (char) i; System.out.println(c); // prints 'A'
char c = 'A'; String s = String.valueOf(c); String s1 = Character.toString(c); // is equivalent to the previous statement
String s = "hello"; char c = s.charAt(0); // extracts the character in position 0 from "hello", // i.e., 'h', and assigns it to the variable c
String s = JOptionPane.showInputDialog("Insert a character"); char c = s.charAt(0);
char c = 'a'; System.out.println(c);