Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6642667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:57:28+00:00 2026-05-25T23:57:28+00:00

in the loop , I make some actions then get and add string to

  • 0

in the loop , I make some actions then get and add string to the list1
after loop: list1 contains 2 strings : OK
now, in another loop I get value on each iteration which return me a string and I would like to check that strings in list1 aren’t available in the second:

for(inti=0;i<nb;i++){
   value= table.getValue(i);
   list1.add(value);
}

for(int j=0;j<nb;j++){
   String toto = table.getValue(i);
   //do other actions

   //here verify that list1 doesn't contain toto
   //I tried :
   assetFalse(table.getValue(i).contains(list1)); //not OK !
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T23:57:29+00:00Added an answer on May 25, 2026 at 11:57 pm
    //here verify that list1 doesn't contain toto
    //I tried :
    assetFalse(table.getValue(i).contains(list1)); //not OK !
    

    First the method is called assertFalse.

    Second you’re checking if toto contains the list ( table.getValue(i) is toto).
    Note that your code could also be read as assertFalse(toto.contains(list1)); (with the spelling fixed and using the assignment above).

    Instead I guess you’d like to do this instead:

     assertFalse(list1.contains(toto));
    

    Also note that in your two loops you iterate over the same collection (table) and the same indices ( 0 to nb-1). Thus list will always contain the values you check for (unless you’re removing them somewhere) and thus your assertation will always fail.

    Finally, please post compilable code: inti=0; won’t compile as well as assetFalse(...) nor String toto = table.getValue(i);, since i isn’t known in that loop (it is out of scope).

    If you want us to help you, please put more effort into your questions.

    Edit

    If you want to compare two collections, you could also use a utility library like Apache Commons Collections, which has methods like CollectionUtils.containsAny(collection1, collection2) (this would return true if at least one element is present in both collections) etc.

    Google Guava should have similar utilities.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have string it contains some code. I want to make some changes on
After trying to make a while(bool) loop and it failing because I couldn't see
In flex component life cycle, after we make some change in a components property,
I'm using $().each() to loop through some items. I want to make sure that
Using powershell I need to loop a series of pdf file and make some
When does it make sense to use Loop fission/distribution if I am compiling for
How do you Make A Repeat-Until Loop in C++? As opposed to a standard
When you make a microsoft batch file, ie: saving @echo off :loop echo HI!
I loop through a bunch of directories recursively. Some of them (like D:\$RECYCLE.BIN\S-1-5-20 )
Some time ago i Wrote a service with a timer that make an action

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.