我尝试在数组中添加东西列表**
public Wrap(String name, Wrap wrap, List<Things> things) {
super(name);
this.bread = bread;
**things.addAll( Arrays.asList( things ) );**
}
**
我得到这个错误:不兼容的类型。必需,Collection<? extends topping>
但推断为“ asList” List<T>
:不存在类型变量的实例,因此List<topping>
符合Topping
您正在试图调用Arrays.asList()
上things
,这已经是一个List
。您可以addAll()
直接通过things
以下方式直接致电:
public Wrap(String name, Wrap wrap, List<Things> things) {
super(name);
this.bread = bread;
things.addAll(new ArrayList(things));
}
然而,这并没有太大的意义添加things
到things
。也许您有一个类变量things
并打算使用this
关键字?
this.things.addAll(things);
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句