Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Check if an ArrayList Contain 2 values?

is there any way to check if a collection contain a value or more with better performance than looping twice with contains?

in other meaning something that would look like this

person.contains("Joe" || "Jasha");
like image 589
Yehia Awad Avatar asked Dec 24 '13 05:12

Yehia Awad


1 Answers

Simply use Arrays class

person.containsAll(Arrays.asList("Jasha","Joe"));
like image 135
Chandrayya G K Avatar answered Sep 29 '22 07:09

Chandrayya G K