• Post Reply Bookmark Topic Watch Topic
  • New Topic

List not working  RSS feed

 
shaf maff
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the following list:

List contactIds = contactIds = new ArrayList();



I try to run this code in my main app:




The problem is with the getContactId method. It keeps giving me an incompatable type error. Do you know where I am going wrong?












.

[ September 23, 2008: Message edited by: shaf maff ]
[ September 23, 2008: Message edited by: shaf maff ]
 
Ola Daniel
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, take a look at this http://www.onjava.com/pub/a/onjava/2005/07/06/generics.html

It should help you figure out the problem.

You have two options, declare your arraylist using generics this way:

or
adjust the getContact method and cast the object to a string (at the risk of getting a class cast exception if the object isn't a string.)

[ September 23, 2008: Message edited by: Ola Daniel ]
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This question is not about servlets, so it doesn't belong in the Servlets forum. I'll move it to a more appropriate forum for you. Please follow the link at the top of the page to continue the discussion.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!