ArrayList的自定义类的有没有。新增()方法:的Java - 自定义类的ArrayList没有add方法
我可以定义对象的的ArrayList:
ArrayList<Object> thing = new ArrayList<Object>();
thing.add(otherThing); // works
然而,当我定义的列表自定义类的东西事物:
ArrayList<Thing> thing = new ArrayList<Thing>();
thing.add(otherThing); // error
Canvas.java:33: cannot find symbol
symbol : method add(java.lang.Object)
location: class java.util.ArrayList<Thing>
thing.add(otherThing);
^
1 error
这可能吗?
感谢
'otherThing'是如何声明的? – 2013-04-23 03:39:48