This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Question with generics Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Question with generics" Watch "Question with generics" New topic
Author

Question with generics

kartik krishnan
Ranch Hand

Joined: Nov 19, 2006
Posts: 63
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 ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Question with generics