I would like to compare two arrays, if at least one value can be found on both arrays.
Scenario #1 : 2
is found in both arrays, so the result is true
.
String[] x = {"1","2","3"};
String[] y = {"2","5","6"};
Scenario #2 : No matching value, so the result is false
.
String[] x = {"1","2","3"};
String[] y = {"4","5","6"};
Is there any built-in method in Java, or any library that can handle this requirement?
I would like to emphasize that I am looking for a Java library or any Java method that can do this out of the box.
The Collection.contains
is not an option because all values in both arrays should be the same in order to return true. (I need to return true if at least one value is similar in both arrays)