count Zeros in short array - Android java.lang

Android examples for java.lang:array

Description

count Zeros in short array

Demo Code

public class Main{

    public static int countZeros(short[] audioData) {
        int numZeros = 0;

        for (int i = 0; i < audioData.length; i++) {
            if (audioData[i] == 0) {
                numZeros++;//  w w  w. j av  a 2s  .co m
            }
        }

        return numZeros;
    }

}

Related Tutorials