将ascii转换为int?
我得到一个ASCII值,我想将其转换为Ineger因为我知道它的整数ASCII值..
int a=53
这是5的ASCII值我希望将其转换为整数
int asciiValue = 53; int numericValue = Character.getNumericValue(asciiValue); System.out.println(numericValue);
int yourInt = Integer.parseInt(yourString);
http://www.cse.wustl.edu/~kjg/java/api/java/lang/Integer.html#parseInt%28java.lang.String%29
如果你确定它是一个int,你可以使用Integer.parseInt();
如果可以保证字符串包含整数:
Integer.parseInt(String)
使用Integer.parseInt()静态方法:
http://download.oracle.com/javase/6/docs/api/java/lang/Integer.html#parseInt(java.lang.String )
使用:
try { int i = Integer.parseInt(StringValue); } catch (NumberFormatException nfe) { System.out.println("NumberFormatException: " + nfe.getMessage()); }
你的意思是单个字符还是字符串?
char ch = int n = Character.forDigit(ch, 10);
要么
int n = ch - '0';
使用Integer.parseInt(String)
或者如果只使用单个字符: int n = (int) (_char - '0')
- Android java.lang.ClassCastException:android.widget.RelativeLayout无法强制转换为android.widget.EditText
- Android jobScheduler不会因jobFinished而停止(params,false)
- 错误:(59,8)错误:无法访问未找到android.support.v4.app.ActivityCompatApi23的ActivityCompatApi23类文件
- 函数返回接口意味着什么?
- 包含在HorizontalScrollView中的TabWidget不会使用ViewPager滚动
- 如何将一个月添加到日期并获得同一天
- 在Java中直接比较2 float / double是否安全?
- Google Datastore Querys会返回陈旧数据
- Android数组无法解析或不是字段