Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Foo<T extends Qux>
- {
- Collection<Bar<T>> bars;
- T qux;
- public Collection<Bar<T>> getBars()
- { return bars; }
- public qux getQux()
- { return qux; }
- }
- class Bar<T extends Qux>
- {
- public void barMethod(T quxarg)
- { // stuff }
- }
- class SomeClass
- {
- public static someMethod(Foo<? extends Qux>... foos)
- {
- for(Foo<? extends Qux> i : foos)
- {
- for(Bar<? extends Qux> j : i.getBars())
- {
- j.barMethod(i.getQux);
- // Error: Cannot convert Qux to capture#1 of ? extends Qux
- // Is there a better way to do this?
- // The type parameter of j is guaranteed to be the same type parameter as i's
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment