0
我正在开发一个听写程序,其中我尝试将学生输入的文本与正确的文本进行比较,但编译时出现错误,这对我没有任何意义。Java长度方法错误
CODE:
String[] list_answer = exercise_english_1.answer.split("\\s+");
String[] list_responce = exercise_english_1.response.split("\\s+");
ArrayList<String> list_error = new ArrayList<String>();
for(int i = 0; i < list_answer.length(); ++i) {
if (list_responce[i].equals(list_answer[i]))
exercise_english_1_statistics.score += (double) 1/list_answer.length();
else
list_error.add(list_responce[i]);
}
错误:
C:\Users\?????\OneDrive\Java\Project\Prototype\Prototype.java:71: error: cannot find symbol
for(int i = 0; i < list_answer.length(); ++i) {
^
symbol: method length()
location: variable list_answer of type String[]
C:\Users\?????\OneDrive\Java\Project\Prototype\Prototype.java:73: error: cannot find symbol
exercise_english_1_statistics.score += (double) 1/list_answer.length();
symbol: method length()
location: variable list_answer of type String[]
C:\Users\?????\OneDrive\Java\Project\Prototype\Prototype.java:208: error: cannot find symbol
for(int i = 0; i < list_answer.length(); ++i) {
^
symbol: method length()
location: variable list_answer of type String[]
C:\Users\?????\OneDrive\Java\Project\Prototype\Prototype.java:210: error: cannot find symbol
exercise_french_1_statistics.score += (double) 1/list_answer.length();
^
symbol: method length()
location: variable list_answer of type String[]
4 errors
PS:对不起,我的英语不好,这不是我的母语...
数组具有'length'字段,而不是'length()'方法。 – Pshemo
也读:[长度和长度()在java中](http://stackoverflow.com/questions/1965500/length-and-length-in-java) – Pshemo
但我有其他类似的数组在我的代码和编译并执行得很好。 –