Forums Register Login

Problem with Generic

+Pie Number of slices to send: Send
Hi, everyone!

I have a following code:


When I'm trying to implement this interfaces, for example this way:

I'm getting an error at line 21: type parameter BigDecimalResult is not within its bounds

Does anyone know what could be the problem?

Thanks in advance!
+Pie Number of slices to send: Send
The problem is that Task's generic type is <T extends TaskResult<T>>. BigDecimalResult does not implement TaskResult<BigDecimalResult> but TaskResult<BigDecimal>. If you change the declaration to "interface Task<T extends TaskResult<?>>" it will compile. Another option is to use two generic types:
This does make it messy, and you only need it if you need the T of TaskResult.
+Pie Number of slices to send: Send
Thanks, Rob!
It's what I needed to know.
+Pie Number of slices to send: Send
You're welcome.
Legend has it that if you rub the right tiny ad, a genie comes out.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 987 times.
Similar Threads
Try to understando generic methods
Not sure whether to override or overload methods in interface
Implementing interface with list of generics
How to correctly use a fixed size thread pool?
Generics in Interfaces
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 00:09:04.