Nick Div
Nick Div

Reputation: 5628

How to convert string representation of an ASCII value to character

I have a String containing ASCII representation of a character i.e.

String test = "0x07";

Is there a way I can somehow parse it to its character value.

I want something like

char c = 0x07;

But what the character exactly is, will be known only by reading the value in the string.

Upvotes: 0

Views: 574

Answers (1)

matejetz
matejetz

Reputation: 520

You have to add one step:

String test = "0x07";
int decimal = Integer.decode(test);
char c = (char) decimal;

Upvotes: 2

Related Questions