How to Check if an ArrayList Contain 2 values?

前端 未结 6 1324
忘掉有多难
忘掉有多难 2021-01-19 09:34

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 loo

6条回答
  •  庸人自扰
    2021-01-19 10:14

    You can also use regex as follows:

    person.toString().matches(".*\\b(Joe|Jasha)\\b.*");
    

    You will get a boolean value indicating whether it is present or not.

提交回复
热议问题