Saturday, June 21, 2014

Java Exercise Nr. 52 (Characters)

Write a program that receives a character and displays its Unicode.

Solution:

public static void main(String[] args) {
Scanner s = new Scanner(System.in);
String str;
char ch;

System.out.print("Enter a character:");
str = s.nextLine();

ch = str.charAt(0);

System.out.print("The Unicode for the character " + ch + " is " + (int)ch + ".");
}

1 comment:

Author