How to pass from String to Char

I have the following:

String a = "\u0043";

I know that is an Unicode char and I want to obtain its ASCII value.
This is an example of I want to do:

String A = "A";

is

int ascii = 65;

or:

String A = "\u0043";

is

int ascii = 67;

Upvotes: 0

Views: 76

Answers (1)

Darkman
Darkman

Reputation: 2981

String A ="\u0043"; //Letter C
int c = A.charAt(0);
System.out.println(c); //Prints 67
        
String B = "A"; //Letter A
int a = B.charAt(0);
System.out.println(a); //Prints 65

Upvotes: 1

Related Questions