次のエラーが表示されるのはなぜですか:cannot find symbol: method add
?これは私のコードです:シンボルが見つかりません:メソッドを追加
import java.util.*
public class ArrayList {
// instance variables - replace the example below with your own
public void processinput(String s) {
int[] a = { 34, 25, 16, 98, 77, 101, 24 };
ArrayList b = new ArrayList();
for (int i = 0; i < a.length; i++) {
int d = a[i];
if (d % 2 > 0) {
b.add(new Integer(d));
}
}
for (int i = 0; i < b.size(); i++) {
System.out.print(b.get(i) + " ");
}
for (int i = a.length - 1; i >= 0; i--) {
System.out.print(a[i] + " ");
}
}
}
どうすればこのエラーを解決できますか?
あなたのコードは私のためにコンパイルされます(私はクラス内のメソッドの中に入れていれば、明らかです)。おそらく 'ArrayList'という名前のクラスをどこかに持っていますか?もしそうであれば、間違って 'java.util.ArrayList'の代わりにそれを使用するかもしれません。 –
可能な複製[シンボルメソッドadd(java.lang.integer)を見つけることができません..実際に問題は何ですか?](http://stackoverflow.com/questions/4801711/cannot-find-symbol-method-add-java -lang-integer-whats-the-problem-actually) –