This section illustrates you how to calculate occurrences
of elements in an array. Occurrences means, the how many times an element occurs
in the array. In this section, you will get more and more help from the given
following program with the complete code.
Program Description:
This program first asks for the length of the array whatever you want to fix and then it takes some inputs for the elements of the array how more you have mentioned for the length of the array. And finally it show the occurrences of each and every element of the array uniquely.
Here is the code of the program:
Output of the program :
Download this example.
Program Description:
This program first asks for the length of the array whatever you want to fix and then it takes some inputs for the elements of the array how more you have mentioned for the length of the array. And finally it show the occurrences of each and every element of the array uniquely.
Here is the code of the program:
import java.io.*;
|
C:\chandan>javac OccurancesInArray.java C:\chandan>java OccurancesInArray How many elements you want to enter in the array: 5 123 chand 453 aaa 123 Occurance of '123' : 2 Occurance of 'chand' : 1 Occurance of '453' : 1 Occurance of 'aaa' : 1 C:\work\chandan>_ |
No comments:
Post a Comment