Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

10
  • Here you comparing first item from firstArray with first item from the second and so on. You need to do double for loop to check if first item from secondArray is in any place in the firstArray. Commented Apr 13, 2017 at 11:15
  • @cbronson1 No actually each element is compared to all second list elemnts withcontains() method. Commented Apr 13, 2017 at 11:24
  • Hmmm, actually I don't want to get boolean ArrayList but ArrayList with values which doesn't match any value in firstArray. I rewrite your code to got that List and surprisingly result are the same as using assertThat(firstArray).containsAll(secondArray); Commented Apr 13, 2017 at 13:20
  • Earlier I rewrite the code the same way as you did now and result are not as expected. Please take a look for my demo: ideone.com/3mjezn This should work this way but I don't get it why your code doesn't act like this Commented Apr 13, 2017 at 13:48
  • Why are you using 2 loops? Do you want to test if strings from second list contains string from first list?! Commented Apr 13, 2017 at 13:57