2014年5月22日星期四

Char type conversion int type , when , and how it is not an assignment ASCII code ? ?

If the value is a char is converted into ASCII 49 , but the value I want to convert or a how to do ?
------ Solution ---------------------------------------- ----


char c = '1';
int i = (int) (c - '0');
System.out.println(i);

------ For reference only ---------------------------- -----------

char c = '1';
int result = Integer.valueOf(String.valueOf(c));
System.out.println(result);

没有评论:

发表评论