本文介绍了ArrayList 方法不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在学习 Java,但遇到了这个 ArrayList
问题:当我尝试使用简单的方法(例如 add
)时,编译器给了我错误.代码如下:
I am learning about Java and I'm stuck with this ArrayList
problem: the compiler give me error when I try to use simple methods, like add
. Here is the code:
public class ArrayList {
public static void main(String[] args) {
ArrayList list = new ArrayList();
list.add("Value A");
list.add("Value B");
list.add("Value C");
}
}
该方法定义在Javadoc.
做起来应该很简单,但我真的不知道我在这里做错了什么.
It should be really simple to do it, but I really don't know what I'm doing wrong here.
推荐答案
您已经创建了自己的 ArrayList
类并且没有使用 内置 Java 类.您还没有定义 add
.
You have created your own ArrayList
class and aren't using the built-in Java class. You haven't defined add
.
这篇关于ArrayList 方法不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!