• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Java 5 question on generics

 
Ranch Hand
Posts: 387
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 2412
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Keith,

Thanks for the reply.
 
reply
    Bookmark Topic Watch Topic
  • New Topic