File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Problem with Generic Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Problem with Generic" Watch "Problem with Generic" New topic
Author

Problem with Generic

Alex Kruglov
Greenhorn

Joined: May 06, 2008
Posts: 8
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!
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19794
    
  20

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Alex Kruglov
Greenhorn

Joined: May 06, 2008
Posts: 8
Thanks, Rob!
It's what I needed to know.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19794
    
  20

You're welcome.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem with Generic