Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class counts {
- public static void main(String[] args) {
- int[] numbers = {1,1,1,1,1,2,3,3,3,6,6};
- int times = 0;
- int currentnumber = 0;
- for (int number : numbers) {
- int current = 0;
- for (int i : numbers) {
- if (number == i) {
- current++;
- }
- if (current > times) {
- times = current;
- currentnumber = number;
- }
- }
- }
- System.out.println("Current Number: "+ currentnumber);
- System.out.println("The number is repeated: " + times + " times");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement