Checking if numbers in array are sorted or reverse sorted
Your version is slightly misnamed.  It's actually isNonincreasingOrNondecreasing.  It returns true for arrays where all the entries are the same value, which is neither increasing nor decreasing.  

If you don't want to duplicate the checks, you can add a bit more logic.

public static boolean isNonincreasingOrNondecreasing(int[] sequence) {
    // clear out equal entries from the beginning
    int i = 1;
    while (i &lt; sequence.length &amp;&amp; sequence[i - 1] == sequence[i]) {
        i++;
    }

    // if there are no entries left, then it is nonincreasing and nondecreasing
    if (i &gt;= sequence.length) {
        return true;
    }

    int previous = sequence[i - 1];
    if (i &lt; sequence.length &amp;&amp; previous &gt; sequence[i]) {
        for (; i &lt; sequence.length; i++) {
            if (previous &lt; sequence[i]) {
                return false;
            }

            previous = sequence[i];
        }

        return true;
    }

    for (; i &lt; sequence.length; i++) {
        if (previous &gt; sequence[i]) {
            return false;
        }

        previous = sequence[i];
    }

    return true;
}


This version only loops once, although it has three loops coded.  It only runs one loop over any section of the array.  

It also gets rid of the Boolean variables.  It can return immediately since it only gets to the loops once it already knows which one to test.