Reputation: 91
I try to add a list of things inside an array **
public Wrap(String name, Wrap wrap, List<Things> things) {
super(name);
this.bread = bread;
**things.addAll( Arrays.asList( things ) );**
}
**
and I get this error:
incompatible types. Required Collection<? extends topping>
but 'asList' was inferred to List<T>
:no instance(s) of type variable(s) exist so that List<topping>
conforms to Topping
Upvotes: 1
Views: 588
Reputation: 12819
You are trying to call Arrays.asList()
on things
, which is already a List
. You can simply call addAll()
directly with things
:
public Wrap(String name, Wrap wrap, List<Things> things) {
super(name);
this.bread = bread;
things.addAll(new ArrayList(things));
}
However this doesn't make much sense to add things
to things
. Perhaps you have a class variable things
and meant to use the this
keyword?
this.things.addAll(things);
Upvotes: 1