I have a method in Java that takes in a generic type:
public <K> void doSomething(List<K> inputList, Function<DB, Map<String, K>> func);
K
is only allowed to to extend either one class or another (A
or B
)
How can I define that in Java?
I have a method in Java that takes in a generic type:
public <K> void doSomething(List<K> inputList, Function<DB, Map<String, K>> func);
K
is only allowed to to extend either one class or another (A
or B
)
How can I define that in Java?
I guess, you can't. You can extend only one class (should be first), and interface. Please take a look on answer: Java Generics Wildcarding With Multiple Classes