• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java 5 question on generics  RSS feed

 
Melinda Savoy
Ranch Hand
Posts: 387
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know it may sound strange but we are just now making the move to Java 5 because we've been working in IBM RAD for so long that we've only had to deal with Java 1.4. Now we've dumped RAD and are working in Eclipse 3.2 and now able to work with Java 5.

At any rate, I have a question on generics. I am having a problem understanding how to convert my code to gel with Java 5 and can't understand some of documentation I've been given for Java 5 generics to fix my problem.

Here is the code that I'm having a problem with:

List<User> userNameList = userDAO.findUserNames(user.getCurrentEntity(), userName + '%');

The section after the "=" is giving me this error:

Type safety: The expression of type List needs unchecked conversion to conform to
List<User>

When I tried to put intert <User> after the findUserNames I get an error stating that findUserNames is not recognized.

Any help from those that know Java 5 generics would be appreciated.

Thanks.
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You will need to modify the findUserNames method to return the List<User> or a subclass of List<User>.
[ November 01, 2006: Message edited by: Keith Lynn ]
 
Melinda Savoy
Ranch Hand
Posts: 387
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Keith,

Thanks for the reply.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!