import java.util.Random; public class ArrayRepeatProblem { public static void print(int i) {System.out.println(i);} public static void print(String s) {System.out.println(s);} public static void main(String[] args) { Random rn = new Random(); final int ARR_SIZE = 10; final int NUM_MAX = 10; int[] arr = new int[ARR_SIZE]; for (int i = 0 ; i < ARR_SIZE ; i++) { arr[i] = rn.nextInt(NUM_MAX); } if (NUM_MAX <= ARR_SIZE) { for (int i = 0 ; i < ARR_SIZE ; i++) { arr[arr[i] % NUM_MAX] += NUM_MAX; } int max = arr[0] / NUM_MAX; for (int i = 0 ; i < ARR_SIZE ; i++) { if (arr[i] / NUM_MAX > max) max = arr[i] / NUM_MAX; } for (int i = 0 ; i < ARR_SIZE ; i++) { if (arr[i] / NUM_MAX == max) print(i % NUM_MAX + " is repeating " + max + " times."); } print("Array : "); for (int j = 0 ; j < ARR_SIZE ; j++) { System.out.print(arr[j] % NUM_MAX + " "); } } else { print("Ups, I dont know how to solve it xd"); } } }