How to convert ASCII to int?

前端 未结 8 1331
独厮守ぢ
独厮守ぢ 2021-01-17 10:08

I am getting an ASCII value and I want to convert it into an integer because I know it\'s an Integer ASCII value.

int a=53; 

This is an ASC

相关标签:
8条回答
  • 2021-01-17 11:00

    Do you mean a single character or a String?

    char ch = 
    int n = Character.forDigit(ch, 10);
    

    or

    int n = ch - '0';
    
    0 讨论(0)
  • 2021-01-17 11:06

    Use Integer.parseInt() static method:

    Oracle Docs Integer.parseInt()

    0 讨论(0)
提交回复
热议问题