# how to check and print the no of times an integer is repeated in an array

how to check and print the no of times an integer is repeated in an array???

suppose my input is 2 4 2 5 2 4 3 4 5 2 then my output should be

2-4 times 4-3 times 5-2 times 3-1 times

January 7, 2011 at 12:07 PM

Hi Friend,

Try the following code:

```import java.util.*;

class  CountNumberOccurrence {
public static void main(String[] args) throws Exception{
int array[]={2,4,2,5,2,4,3,4,5,2};
for(int counter =0;counter<array.length;counter++){
int n= array[counter];
int count=0;
for ( int i=0; i<array.length; i++){
if (n==array[i])
count++;
}
boolean flag=false;
for(int j=counter-1;j>=0;j--){
if(n==array[j])
flag=true;
}
if(!flag){
System.out.println(n+" - "+count+" times ");
}
}
}
}
```

Thanks

how to check and print the no of times an integer is repeated in an array
how to check and print the no of times an integer is repeated in an array  how to check and print the no of times an integer is repeated in an array??? suppose my input is 2 4 2 5 2 4 3 4 5 2 then my output should be 2-4
How can print integer in method
How can print integer in method   a method call process public process(int jobid,int remain){ } how to print int jobid ,int remain in for loop jobid in proc[0],remain in proc[1],both show in text file how to print proc[0
How to Print Array in JavaScript
How to Print Array in JavaScript In this section you will learn about Array... Now, here is the example how to declare and access array. <!DOCTYPE html>... Array example</h1><p><h2>Click to print the array element</h2
Java Reverse integer array
Java Reverse integer array In this tutorial, you will learn how to reverse integer array. Here, we have created a method to reverse an array which has been passed as a parameter and returns a new array with all the elements in reverse
Reverse integer array program
Reverse integer array program  Been tasked with the following question: Write a method that accepts an integer array and returns a new array with all the elements in reverse order. For example, if the input array is [2, 4, 6, 8
how i can print the elements before a spicific value in array queue?
how i can print the elements before a spicific value in array queue?  how i can printall elements befor the spicific value and print this value also   Hi Friend, Try this: <html> <script> var arr=new Array
ModuleNotFoundError: No module named 'print_array'
'print_array' How to remove the ModuleNotFoundError: No module named 'print_array' error? Thanks   Hi, In your python environment...ModuleNotFoundError: No module named 'print_array'  Hi, My Python
How to put text file numbers to array and check the position of numbers?
How to put text file numbers to array and check the position of numbers?   I have numbers in text file data.txt 12 9 8 3 1
Simplest way to print an array in Java
Simplest way to print an array in Java  Simplest way to print an array in Java
print array in following format
print array in following format  i want print two array in following format first array= 1,2,3,4,5,6,7,8,9 second array=11,12,13,14,15,16,17,18,19 i...; Here is a code that displays the array values in the following pattern: 1 2
How to Remove Repeated Characters from the String?
How to Remove Repeated Characters from the String?  Hi, I trying to develop an application which will remove the repeated characters from... the example of how to remove repeated characters from the string. Please visit
how to print the average of each column of 2d n*m array using java
how to print the average of each column of 2d n*m array using java  here is my code: import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Scanner; public
JavaScript array print
JavaScript array print     ... print them wherever we wish. Here is the simple example of array printing which...;); } Above lines of code will print all the elements of the array. Here
: ModuleNotFoundError: No module named 'odoo8-addon-res-currency-print-on-check' How...ModuleNotFoundError: No module named 'odoo8-addon-res-currency-print-on-check...-print-on-check' error? Thanks   Hi, In your python
: ModuleNotFoundError: No module named 'odoo8-addon-res-currency-print-on-check' How...ModuleNotFoundError: No module named 'odoo8-addon-res-currency-print-on-check...-print-on-check' error? Thanks   Hi, In your python
How to declare array in Java?
of declarating integer array: int[] nums = new String[]{1,2, 5, 7}; Check...How to declare array in Java?  Hi, How to declare array in Java? Thanks   Hi, Following is a code of declaration of String array
print selected checkbox names in array without form tag
print selected checkbox names in array without form tag  Hi everyone ... I have problem in my program. I have hashmap i.e. collection , my code is as follows [code] <%! private HashMap<Integer, Domain>domainmap
how to print the server time
how to print the server time  how to print the server time in jsp and update time in fix interval
how to print dot in python without newline
how to print dot in python without newline  Hi, I a debugging... to print 20 dots without new line. Is there any easy solution? how to print dot...); .......... You can also define a variable to print the no of times
how to print dot in python without newline
how to print dot in python without newline  Hi, I a debugging...? how to print dot in python without newline?ADS_TO_REPLACE_2 Can I use variable...); .......... You can also define a variable to print the no of times and then use
How to Prepend Array in PHP
How to Prepend Array in PHP  hi, How can i prepand array in PHP...;The original array is:</b><br/>"); print_r(\$array);array_unshift(\$array... at the beginning:</b><br/>"); print_r(\$array); ?> Thanks
Create array of random size
Create array of random size In this tutorial, you will learn how to create a randomly sized integer array. For this, we have declared an array and using the Random class, we have set the random size to array. We have stored
How to calculate average of array in Java?
How to calculate average of array in Java?  Hi, I have an integer array and I want to calculate the average of the values in it. How to calculate... of the array. This way you can achieve the result. Check source code at Average
How to print this Format exactly?
How to print this Format exactly?   * * * & reverse
How to print this in java?
How to print pattern in Java?  How to print a particular pattern in Java...;  How to print this in java
how to print the server time
how to print the server time  i want to print database time in clintside and update time in every secound without creating connection to database for each time. how can i do
How to change object item to integer item
How to change object item to integer item  How to change objectitem to integer item?thankyou
how to print String as pattern ?
how to print String as pattern ?  i have a one String name ="rajesh" i want to print pattern like r * ra ** raj raje rajes rajesh please help me
How does Java handle integer overflows and underflows?
How does Java handle integer overflows and underflows?   hi, How does Java handle integer overflows and underflows? Thanks
how to check gremlin version
how to check gremlin version  Hi, I am inside gremlin console and want to check the version. How to check gremlin version? thanks   Hi...; Gremlin.version() ==>3.3.1 this will print the gremlin version. Thanks
Can u print in turbo c 9 8 7 6 5 4 3 2 1 0 using pre increment operator Only use print ++a in the same printf() command ten times)
Can u print in turbo c 9 8 7 6 5 4 3 2 1 0 using pre increment operator Only use print ++a in the same printf() command ten times)  Can u print in turbo c 9 8 7 6 5 4 3 2 1 0 using pre increment operator Only use print
Can u print in turbo c 9 8 7 6 5 4 3 2 1 0 using pre increment operator Only use print ++a in the same printf() command ten times)
Can u print in turbo C  Can u print in turbo c 9 8 7 6 5 4 3 2 1 0 using pre increment operator Only use print ++a in the same printf() command ten times
how to print - Java Beginners
how to print  how to print something on console without using System.out.print() method ?  Hi Friend, You can use PrintWriter to write anything on the console. import java.io.*; public class Print{ public static
How to print UIButton id
How to print UIButton id  How to get the id of the button in the IOS application? Thanks   Hi, You can use the following code: - (IBAction)btnClicked:(id)sender { UIButton *button = (UIButton *)sender; int
how to print the following pattern
how to print the following pattern  Hello hEllo heLlo helLo hellO pls reply soon its an emergency   class StringPattern { public static void main(String[] args) { String st="hello
How to design a foot print on the sand, print on the sand, print
How to design a foot print on the sand       You might have seen foot prints on the sand field. Do you think, it can be design in the photoshop, yes I have done here. I have used
how to print pdf format
how to print pdf format  Hi every body iam doing school project iam using backend as oracle front end java .how to print student marks list /attendence in pdf format. please help me. thanks in advance.   Here
How to Convert ArrayList to Array?
How to Convert ArrayList to Array?  Hi, I am trying to learn to Convert ArrayList to Array. How it is possible? How to Convert ArrayList to Array... ArrayList to Array. Check more examples at Convert ArrayList to Array. Thanks
How to Print a Stack Trace Message
How to Print a Stack Trace Message  Debugging of Java program requires... times you have to print the detailed error message on the console..._TO_REPLACE_1 catch (Exception e){    e.printStackTrace(); } Check how
how to create array in python
how to create array in python  Hi, how to create array in python? I want to create an array in Python and add some values to it. Thanks   Hi, You can create a new array with the code myArray = [] and after
Search an elements in the array
Search an elements in the array In this section we will discuss about how to check the availability of an element in the array. Array is a collection... of this program we are going to check the element in the array whether the elemnt
How to: generic array creation
How to: generic array creation  How to: generic array creation
array
accepts a pointer to integer which represents an array of integer.After that this method prints the entire of the array numbers to the monitor. include... will print only the designated portion of the array. Validate low and high; if either
How to print current time in r?
How to print current time in r?  Hi, I am learning and want to print current date and time on console. How to print current time in R Programming...:01:31 2017" Thanks   Hi, Check 100s of tutorials of r programming
ModuleNotFoundError: No module named 'repeated-test'
'repeated-test' How to remove the ModuleNotFoundError: No module named 'repeated-test' error? Thanks   Hi, In your python...ModuleNotFoundError: No module named 'repeated-test'  Hi, My
how to print JInternal frame component ?
how to print JInternal frame component ?  hello sir, i devalop a swing application .but problem is that how display report & print it. some data prefech from database & keep to jtable but how it is print with table
How do you get the size of an array in Python
How do you get the size of an array in Python  Hi, I want to get the size of my array in Python. How do you get the size of an array in Python? How... of an array in Python: size=200 myArray = [0] * size print(len(myArray
count the repeated character in one string
count the repeated character in one string  to find the how character... 'a 'was repeated )   Hi Friend, Try the following code: import...; } if(!flag){ System.out.println("Character :"+ch+" occurs "+count+" times
how to print spark dataframe data
how to print spark dataframe data  Hi, I have a dataframe in spark and i want to print all the data on console. How it can be done. how to print... is in "data" variable and you want to print it. Its simple and one line function to print
how to print spark dataframe data
how to print spark dataframe data  Hi, I have a dataframe in spark and i want to print all the data on console. How it can be done. how to print... is in "data" variable and you want to print it. Its simple and one line function to print