public class CompareArray {
public static void main(String[] args) {
String[] a = {"a","b","c"};
String[] b = {"a","b","c","d"};
System.out.println(compareArray(a, b));
System.out.println(compareArray(b, a));
/**
* 找出a数组中不在b数组中的值
*/
String[] notInArray = notInArray(b,a);
if(notInArray != null && notInArray.length > 0){
for(int i = 0; i < notInArray.length; i ++){
System.out.println(notInArray[i]);
}
}
String[] c = {"a","d"};
String[] d = {"a","e","f"};
/**
* 找出的是d中不在c中的字符串,输出,e/f
*/
String[] notInArray2 = notInArray(c,d);
if(notInArray2 != null && notInArray2.length > 0){
for(int i = 0; i < notInArray2.length; i ++){
System.out.println(notInArray2[i]);
}
}
/**
* 实际业务场景
* 找出新选择的人员不在已发送的人员中的人
*
Java比较两个数组
最新推荐文章于 2023-08-05 11:39:59 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)