【发布时间】:2011-11-27 08:13:03
【问题描述】:
我正在尝试使用 parseInt 方法转换字符串的前两个字符,但我不能。它应该看起来像这样:
String firstChars = IntMessage.substring(0,2);// firstChars is a String that corresponds to the first two characters of the string.
message=ASCII[(Integer.parseInt(firstChar))-32];//The message variable is a String that is supposed to take a firstChars variable and make it an integer so it can be used by the ASCII array in determining which element of the array is to be concatenated to the message String.
例如,如果前两个字符是 98,我想取那个子字符串并将其转换为 int。
【问题讨论】:
-
这看起来/应该/有效。您是否收到特定的编译器/运行时错误?
-
定义“不能”...当然还要发布实际代码来演示问题。
-
这是java程序,很臭
标签: java char substring parseint