About your code, sorting (Collections.sort(arr);
) will totally prevent you from finding the solution.
I’ll help in pseudocode
Given a counter c
A max counter m
A variable for the max element, e
And an array a
For every element in the array a
If the element matches the previous element
increment the count c, and:
if the count c > m:
set m to c, and e to the current value
If it doesn't match the previous, reset the count to 1
Then after all this, the result is e, c times