Article

判断两个数组是否存在相同元素

java 复制代码
boolean has = false;
String[] strOne= {"c","b","a","d"};
String[] strTwo= {"a","b","d","g"};
for (int i = 0; i < strOne.length; i++) {
    if (ArrayUtils.contains(strTwo, strOne[i])) {
        has = true;
        break;
     }
}

System.out.println(has )
评论
0 条评论