To determine whether two arrays have the same elements is to find the
intersection. The function of intersection is not retainAll. The code is as follows:
boolean has = false;
String[] strOne= {
"c","b","a","d"};
String[] strTwo= {
"a","b","d","g"};
HashSet<String> set = new HashSet<>(Arrays.asList(strOne));
set.retainAll(Arrays.asList(strTwo));
if(set.size() > 0){
has = true;
}