count Null in an array - Android java.lang

Android examples for java.lang:array

Description

count Null in an array

Demo Code


//package com.book2s;

public class Main {
    public static <T> int countNull(T[] src) {
        int ret = 0;
        int srclen = src.length;
        for (int i = 0; i < srclen; ++i) {
            if (src[i] == null) {
                ++ret;/*from   www . j  av  a 2 s. c o  m*/
            }
        }
        return ret;
    }
}

Related Tutorials