public class project5{
public static void main(String args[]){
String[] storage = {"123457897", "123456","654654654"};
int current;
current = Integer.parseInt(storage[1].subString(1,5));
System.out.println(current);
}
}
因此,我尝试在数组的第一个内容中获取前5个数字并将其解析为整数并将其存储为变量current。它给了我错误:
test.java:5: error: cannot find symbol
current = Integer.parseInt(storage[1].subString(1,5));
^
symbol: method subString(int,int)
location: class String
1 error
我做错了什么?
答案 0 :(得分:1)
String类没有subString
方法。只有substring
(全部小写)。
http://docs.oracle.com/javase/7/docs/api/java/lang/String.html
对于变量,类和方法名称的重要性。