Java: Return unknown generic type in method -
the method
filter<t,u> connect(final filter<t,u> filter) { ... return filter }
is in class
class pipe<t>
i error "cannot resolve u". idea generically return same filter same 2 types without knowing u type. how do that?
the goal able chain without providing type parameters, when not necessary because not modified:
(new pipe<integer>).connect(new filter<>(...)).connect(new pipe<>)...
the second pipe after filter in above expamle shall implicitly of generic type integer.
it looks trying make method generic. add generic type u
signature right before return type:
<u> filter<t,u> connect(final filter<t,u> filter) { ... return filter }
Comments
Post a Comment