A priceless Frequency of element in an array program
For more programshttps://wordpress-343193-1101484.cloudwaysapps.com/count-words-start-and-end-with-a-vowel
Write a program to print the frequency of element in an array.
For more programs
An excellent String program to count words start and end with a vowel
import java.io.*;
class frequency
{
public static void main()throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the size of the array");
int n=Integer.parseInt(br.readLine());
int Arr[]=new int[n];
int FREQ[]=new int[n];
int visited=-1;
System.out.println("Enter the values");
for(int i=0;i<n;i++)
{
Arr[i]=Integer.parseInt(br.readLine());
}
for(int i=0;i<n;i++)
{
int count=1;
for(int j=i+1;j<n;j++)
{
if(Arr[i]==Arr[j])
{
count ++;
FREQ[j]=visited;
}
}
if(FREQ[i]!=visited)
{
FREQ[i]=count;
}
}
System.out.println("------------------------------------------");
System.out.println("ELEMENT"+"\t"+"FREQUENCY");
System.out.println("------------------------------------------");
for(int i=0;i<n;i++)
{
if(FREQ[i]!=visited)
{
System.out.println(Arr[i]+"\t"+FREQ[i]);
}
}
}
}Output:
Enter the size of the array
4
10
20
10
15
ELEMENT FREQUENCY
10 2
20 1
15 1
For java videos click
https://www.youtube.com/user/trushna.tej
Related Posts
Continue learning with these related articles

String Methods in Java for ICSE Class 10: 25 Output Questions with Answers
ICSE Class 10 Computer Applications practice on String class methods: length, charAt, indexOf, lastIndexOf, substring, replace, trim, compareTo, equals and more, with 25 board-style output questions and step-by-step answers.

Special Number Programs in Java for ICSE: Armstrong, Spy, Neon, Disarium, Pronic and More
Every special number asked in ICSE Computer Applications – prime, perfect, Armstrong, palindrome, automorphic, neon, spy, Niven, duck, buzz, Disarium, special and pronic numbers – with definitions, examples and one complete Java program that checks them all.

Math Library Methods in Java for ICSE Class 9 (with Outputs)
ICSE Class 9 Computer Applications notes on the Java Math class: sqrt, cbrt, pow, abs, max, min, ceil, floor, round, rint and random, with return types, tricky negative-number outputs and Java expressions for formulas.