Array is MinMax Equal or Not An array is defined to be maxmin equal if it contains at least two different elements and the number of times the maximum value occur is the same as the number of times the minimum value occur. So {11, 4, 9, 11, 8, 5 , 4, 10} is maxmin equal, because the max value 11 and min value 4 both appear two times in the array.


if the input array is {} , isMaxMinEqual should return false (array must have at least two different elements) status = false;
if the input array is {2}, isMaxMinEqual should return false (array must have at least two different elements).
if the input array is {1,1,1,1,1,1}, isMaxMinEqual should return false (array must have at least two different elements). 
if the input array is {2,4,6,8,11}, isMaxMinEqual should return true (Both max value(11) and min value 2 appear exactly one time).
if the input array is {-2,-4,-6,-8,-11}, isMaxMinEqual should return true(Both max value(-2) and min value -11 appear exaclty one time).


I wrote the class MaxMin which satisfied the above condition.

public class MaxMin {

public static void main(String args[]) {
    System.out.println("The result is: " + isMaxMinEqual(new int[]{2, 2}));
}

public static boolean isMaxMinEqual(int[] a) {
    boolean status = false;
    int count = 0;
    if (a.length &lt; 2) {
        status = false;
        return status;
    }
    for (int i = 1; i &lt; a.length; i++) {
        if (a[i - 1] != a[i]) {
            count++;
        }
    }

    int max = a[0];
    int min = a[0];
    for (int i = 0; i &lt; a.length; i++) {
        if (a[i] &gt; max) {
            max = a[i];
        } else if (a[i] &lt; min) {
            min = a[i];
        }
    }

    int maxCount = 0;
    for (int j = 0; j &lt; a.length; j++) {
        if (a[j] == max) {
            maxCount++;
        }
    }

    int minCount = 0;
    for (int j = 0; j &lt; a.length; j++) {
        if (a[j] == min) {
            minCount++;
        }
    }
    System.out.println(count);
    System.out.println("max is: " + max);
    System.out.println("min is: " + min);
    System.out.println("Max Count is: " + maxCount);
    System.out.println("Min Count is: " + minCount);

    if (maxCount == minCount &amp;&amp; count &gt;= 1) {
        status = true;
    }

    return status;
}
}
Varags

Since Java 1.5, you can use varargs in your method so that you can pass in a sequence of elements, instead of an explicit array:

public static boolean isMaxMinEqual(int... values) {
    // use values like a normal int[] array
}


Variables assignment

You have declared status right at the start, but it's actually redundant as you can simply return from the method directly in the places where you use them:

if (a.length &lt; 2) {
    // status = false;
    // return status;
    return false; // shorter and clearer
}
// ...
/*
if (maxCount == minCount &amp;&amp; count &gt;= 1) {
    status = true;
}
return status;
*/
return maxCount == minCount &amp;&amp; count &gt;= 1; // no need to set status = true


'Debug' statements

System.out.println(count);
System.out.println("max is: " + max);
System.out.println("min is: " + min);
System.out.println("Max Count is: " + maxCount);
System.out.println("Min Count is: " + minCount);


These look like 'debug' statements where the developer (or user) is manually checking that the counting is done correctly. Usually, this should be done through a logging framework (so that the verbosity can be adjusted), or be eliminated entirely. It does not serve a direct purpose as to the method's usage.

Iterations

Your approach has to iterate through the array three times:


Find the min/max.
Count the max.
Count the min.


In fact, these can be done in one pass:

int min = Integer.MAX_VALUE;
int max = Integer.MIN_VALUE;
int minCounter = 0;
int maxCounter = 0;
for (int i : values) {
    if (i &lt; min) {
        min = i;
        minCounter = 1;
    } else if (i == min) {
        minCounter++;
    }
    if (i &gt; max) {
        max = i;
        maxCounter = 1;
    } else if (i == max) {
        maxCounter++;
    }
}
return minCounter == maxCounter &amp;&amp; min != max;


The idea here is that when you need to reset your min/max values, you can just reset your counters to 1 and proceed, instead of having to iterate again.

If you do not mind extra ternary operators, you can sort of combine both if branches per min/max too:

int min = Integer.MAX_VALUE;
int max = Integer.MIN_VALUE;
int minCounter = 0;
int maxCounter = 0;
for (int i : values) {
    if (i &lt;= min) {
        minCounter = 1 + (i == min ? minCounter : 0);
        min = i;
    }
    if (i &gt;= max) {
        maxCounter = 1 + (i == max ? maxCounter : 0);
        max = i;
    }
}
return minCounter == maxCounter &amp;&amp; min != max;