
write a java program which will take 10 elements as command line arguments and count how many times 3 occurs in array

Java occurrence of a number in an array
import java.util.*;
class ArrayExample{
public static void main(String[]args){
int count=0;
Scanner input=new Scanner(System.in);
System.out.println("Enter Array Elements: ");
int array[]=new int[10];
for(int i=0;i<array.length;i++){
array[i]=input.nextInt();
}
for(int i=0;i<array.length;i++){
if(array[i]==3){
count++;
}
}
System.out.println("\n3 occurs "+count+" times.");
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.