Forums Register Login

Question with generics

+Pie Number of slices to send: Send
Hi I am learning generics and I hope that this is not a silly question.

If I have an interface Foo<T>, having one method T getById(int id) whose implementation I defined in a file, which has two Java Classes. The implementation of Foo<T> is not public class but with default access scope.


In AnotherClass.java, I have


and


I have two questions,

1) When I try to use the statement



I get an error "Can not object of type User". I would like to to know why

2) When I try to use the implementation reference in AnotherClass, I have to specifically cast it .To show an example



which in turn throws a warning. is there a way by which I can remove the warnings and not suppress them.

Thanks for your help

[ Corrected closing code tag and disabled smilies. -ds ]
[ February 04, 2008: Message edited by: Dirk Schreckmann ]
Life just hasn't been the same since the volcano erupted and now the air is full of tiny ads.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 685 times.
Similar Threads
Generics
Generics
Generics
Generics
Question with generics Please help
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 13:10:46.