• Post Reply Bookmark Topic Watch Topic
  • New Topic

comparing two list values  RSS feed

 
sen senk
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
iam entering the values as 1234.5678,3456 after submit I have to check whether th enterd valus are present in Db.even If the the entered values and database returned values are same its not satisfying this condition if((splittedTokens).contains(Rq)). here is the code please check it.

 
Martin Vajsar
Sheriff
Posts: 3752
62
Chrome Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It seems that your problem is not database related, so I have moved your question into a forum which is dedicated to general Java questions. Also, for better readability, I've added code tags to your post. You can do so yourself when creating a post, the exact way is described here: UseCodeTags.

You're right that the problem is in this condition: if((splittedTokens).contains(Rq)). This condition checks whether the list splittedTokens contains the list Rq itself. It does not check whether the list contains individual items contained in Rq. You could use the containsAll() method, which would return true if and only if the splittedTokens list contained all the objects which are present in the Rq list. This might not be exactly what you want, but only you can know.

You might want to read the Collections tutorial, which is a great way to learn more about ArrayLists and other collection classes, and the the Generics tutorial, which help you write safer code if you're using Java 5 or higher.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!