| Author |
Generics problem
|
Ronwaldo Cruz
Ranch Hand
Joined: Oct 17, 2006
Posts: 69
|
|
Hi, I have written a piece of code show below:
The problem is that the interface method Dog.getOwner seems to have been successfully "implemented" by ConcreteDog.getHunter. However, Dog.setOwner doesn't seem to recognize ConcreteDog.setHunter as a suitable implementation. The 2 looks the same to me. Can somebody please help?
|
 |
subodh gupta
Ranch Hand
Joined: Jul 23, 2007
Posts: 203
|
|
Hi,
You cannot use extends in both the get and put logic you should use extends for getting and super for putting a variable of a type.
|
http://subodh-gupta.blogspot.com
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
It seems to me that you want to connect the Person type in both getOwner and setOwner. Changing the T to a class generic type could solve this:
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Ronwaldo Cruz
Ranch Hand
Joined: Oct 17, 2006
Posts: 69
|
|
|
This helped. Thanks
|
 |
 |
|
|
subject: Generics problem
|
|
|