爲什麼我收到以下錯誤: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`,你可能的意思。 – 2011-01-25 10:29:42
[找不到符號方法add(java.lang.integer)..實際上是什麼問題?](http://stackoverflow.com/questions/4801711/cannot-find-symbol-method-add-java -lang-integer-what-the-problem-actually) – 2011-01-26 07:55:58