2016-06-11 19 views
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:私の悪い英語のため申し訳ありませんが、それは...私の母国語ではありません

+3

配列には 'length()'メソッドではなく 'length'フィールドがあります。 – Pshemo

+0

も読んでください:[長さと長さ()のJavaで](http://stackoverflow.com/questions/1965500/length-and-length-in-java) – Pshemo

+0

しかし私は私のコード内の他の同様の配列の括弧を持っているコンパイルして実行してください。 –

答えて

1

配列にはありませんlength()メソッドを持っていれば、length publicメンバー:

for(int i = 0; i < list_answer.length; ++i) { 
    // Here (note: no()) -----^ 
関連する問題