So, I need to write a code where I print the most frequent character in an array. If there is, only one then just print that character, if there are 2 then print both and if there are none then print no number is missing. I have got it to find the most single frequent value, but I can't figure out how to make it print if there are more than one frequent characters.
public class ArrayOfNumbers {
public static void main (String []args) {
int [] array = {2,3,5,1,2,3};
int n = 6;
System.out.println(findMostFrequent);
}
public static int findMostFrequent(n, array) {
int counter = 1;
int tempCounter;
int mostFrequent = array{0};
int temp = 0;
for (int i = 0; i < array.length - 1; i++) {
temp = a{1};
tempCounter = 0;
for (int j = 1; j < array.length; j++) {
if (temp == a[j]){
tempCount++
}
if (tempCounter > counter){
mostFrequent = temp;
counter = tempCounter;
}
}
return mostFrequent;
}
}
}