Create a 10 element integer array and store some integer values display as the counting of 0.

public class JavaEx {
    public static void main(String args[]) {

        int numbers[] = {10,15,0,0,6,0,0,1,6,4};
        int x,count,len;

        count = 0;
        len = numbers.length;

        for(x= 0; x < len; x++)
        {
            if(numbers[x]==0)
            {
                System.out.println(numbers[x]);
                count++;
            }
        }
        System.out.println(count);
    }

}

above examples  int numbers[] = {10,15,0,0,6,0,0,1,6,4};  here there is 4 zeros.

Output display as

0
0
0
0
4

 

admin

Recent Posts

How to Check Laravel Print Version: A Simple Guide

Laravel Print Version: An Essential Guide Laravel is a powerful PHP framework widely used for…

2 hours ago

How to Laravel cache clear

Laravel cache clear , you can use the Artisan command-line tool that comes with Laravel.…

14 hours ago

Installing Vue.js in Laravel Project

Vue.js is a powerful JavaScript framework for creating dynamic user interfaces, while Laravel is a…

14 hours ago

Do I Return in Void Function in Java?

In Java, a void function (or method) does not return any value. However, you can use the return statement…

24 hours ago

Is Java Hard to Learn?

Is Java Hard to Learn is it True? Java is one of the most popular…

1 day ago

How to generate random with weight java

Generating Random Numbers with Weights in Java Random number generation with weighted probabilities is a…

1 day ago