为什么我收到以下错误: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