Martin Schröder
Martin Schröder

Reputation: 4591

Define a Collection of types that implement multiple interfaces?

I can define a class of generic types with multiple interfaces like this:

public class MyList<E extends foo & bar & fum> extends ArrayList<E>

How can I define a method parameter (or a variable) to be of a Collection of base types that implement multiple interfaces?

Upvotes: 0

Views: 66

Answers (1)

Konstantin Yovkov
Konstantin Yovkov

Reputation: 62864

Something like :

public <E extends foo & bar & fum> void test(Collection<E> parameter) {
  ...
}

Note that the E type here is method-scoped.

Upvotes: 4

Related Questions