java: check if any element in array 1 is present in array 2
问题 I am fairly new to java streams and wonder whether there is an easy solution using java streams to check if any element in array 1 is also present in array 2 example: array1 = ["banana","apple","cat"] array2 = ["toast","bread","pizza","banana"] --> return true array1 = ["banana","apple","cat"] array2 = ["toast","bread","pizza"] --> return false Thanks! 回答1: Just use Collections.disjoint. This method checks if any elements of the both arrays are common. Collections.disjoint(Arrays.asList