find the maximum occur number in an integer
You are passed an integer parameter, and you have to return an integer.  I do not see it as worthwhile converting to a string for the counting.  Better to count the digits directly from the original integer.  MOD (%) 10 will give you the last integer, and DIV (/) 10 will shift the remainder along one position.

You may have to be careful with 0 and negative numbers with this method, otherwise you might get unexpected results.

As will as finding the most common digit you also have to find if there are any other digits with the same frequency.  As you look for a new higher maximum, look for other digits with the same count and keep a note if they exist.

This is my code:

public static int maxOccurDigit(int a) {

    // Zero is a special case.
    if (a == 0) {
        return 0;
    }

    // Numbers != 0.
    int[] digitCounts = new int[10];

    // Ensure a positive
    if (a &lt; 0) {
        a *= -1;
    }

    while (a &gt; 0) {
        digitCounts[a % 10] += 1;
        a /= 10;
    }

    // Find max count and occurrences.
    int maxCount = digitCounts[0];
    boolean sameCounts = false;
    int digit = 0;
    for (int i = 1; i &lt; digitCounts.length; i++) {
        if (digitCounts[i] &gt; maxCount) {
            maxCount = digitCounts[i];
            sameCounts = false;
            digit = i;
        } else if (digitCounts[i] == maxCount) {
            // Digits with equal counts.
            sameCounts = true;
        }
    }

    // Check for multiple max counts.
    if (sameCounts) {
        return -1;
    }

    // Valid single max digit
    return digit;

} // end maxOccurDigit()