乔山办公网我们一直在努力
您的位置:乔山办公网 > excel表格制作 > 如何判断某个数组中是否存在某个元素-excel判断数组,excel数组函数

如何判断某个数组中是否存在某个元素-excel判断数组,excel数组函数

作者:乔山办公网日期:

返回目录:excel表格制作




1、使用List:

public static boolean useList(String[] arr, String targetValue) {
    return Arrays.asList(arr).contains(targetValue);
}

2、使用Set:  

public static boolean useSet(String[] arr, String targetValue) {
    Set<String>
    set = new HashSet<String>(Arrays.asList(arr));
    return set.contains(targetValue);
}

3、使用循环判断:

public static boolean useLoop(String[] arr, String targetValue) {
    for(String s: arr){
        if(s.equals(targetValue))
            return true;
    }
    return false;
}

4、使用Arrays.binarySearch():

public static boolean useArraysBinarySearch(String[] arr, String targetValue) {
    inta =  Arrays.binarySearch(arr, targetValue);
    if(a> 0)
        return true;
    else
        return false;
}

一般老说,用countif、find、mid、substitute都可以对一个数组中是否存在某元素作出判断。
上传带行列号的有数据示例的表格截图,清楚说明已知条件,达成什么样的结果,才能给你准确的答案。

=SUMPRODUCT(1*({0,2,5,6,8}=A1))
不为0说明属于
数组可以用数据区域来代替:=SUMPRODUCT(1*(B1:B5=A1))

相关阅读

关键词不能为空
极力推荐

ppt怎么做_excel表格制作_office365_word文档_365办公网