How to get a character by its code?

There is an ASCII table. I have a value from the Oct column. How to get a symbol for exactly this value? I tried the options but it was on Dec

  • Do you have a value from Oct as a string? - D-side
  • string .. number .. no difference. - Tsyklop
  • There is a difference. The number has no number system. Only its string representation. - D-side
  • @ D-side I can convert to string. mean it. - Tsyklop

1 answer 1

Oct is an octal number system (Octal). Use

 int dec = Integer.parseInt(oct, 8); 

to convert to the 10th number (this will be a Dec - Decimal column), and then use

 char c = (char) dec; 

to get an ASCII character.


Full example:

 String oct = "053"; int dec = Integer.parseInt(oct, 8); System.out.println("В десятичной с.с. будет " + dec); System.out.println("Знак ASCII будет " + (char) dec); 

As a result, we get in the answer + .

ideone