Validating UTF-8 byte array
Logic

Never omit the optional braces like that.  Think of yourself as a contributing factor to a future coding accident.  If you really want to omit braces, then put the statement on the same line, so that there is no possibility of misinterpretation.

The function does not check for overlong encodings, invalid byte sequences, or invalid code points.  Those caveats should be declared in JavaDoc.

I would eliminate the length &gt; 6 check, as 6 is a magic number.  You don't need that special case anyway.

I would also incorporate the length == 1 special case into the regular logic.

In general, text is more likely to contain shorter UTF-8 sequences than longer ones, so you might as well handle the shorter cases first to save a few CPU cycles.

Rather than setting n to be the number of trailing bytes, set it to be the expected length of the array.  I'd rename n → expectedLen to be more descriptive.  That makes the code more readable (and saves one pointless subtraction).

Eliminate the bit-shifting.  Just AND with the bitmask to specify which bits you are interested in inspecting.

public static boolean validate(byte[] bytes) {
    int expectedLen;
    if      (bytes.length == 0)                     return false;
    else if ((bytes[0] &amp; 0b10000000) == 0b00000000) expectedLen = 1;
    else if ((bytes[0] &amp; 0b11100000) == 0b11000000) expectedLen = 2;
    else if ((bytes[0] &amp; 0b11110000) == 0b11100000) expectedLen = 3;
    else if ((bytes[0] &amp; 0b11111000) == 0b11110000) expectedLen = 4;
    else if ((bytes[0] &amp; 0b11111100) == 0b11111000) expectedLen = 5;
    else if ((bytes[0] &amp; 0b11111110) == 0b11111100) expectedLen = 6;
    else    return false;

    if (expectedLen != bytes.length) return false;

    for (int i = 1; i &lt; bytes.length; i++) {
        if ((bytes[i] &amp; 0b11000000) != 0b10000000) {
            return false;
        }
    }

    return true;
}


Interface design

It's rarely useful to validate a single character: usually, you'll want to validate a whole string.  You should name your function to avoid giving the impression that it checks for multi-character strings.

In Java, functions that perform a test and return a boolean are conventionally named isSomething() or hasSomething().  A function named validate() suggests that it performs an action as a side-effect, perhaps throwing an exception on failure.

Therefore, I'd rename your function to isValidChar(byte[] bytes).

So, what if I need to validate a string?  I'd have to somehow chunk it up into right-sized byte arrays first.  That's not really possible without examining the string using similar logic to what is in the function itself.  Even then, it would be wasteful to construct a byte array just for the function call.  Therefore, I think that it would be more useful to provide a function that validates a string.  To go further, you could make such a function return something more informative than just a boolean.

/**
 * Returns the number of UTF-8 characters, or -1 if the array
 * does not contain a valid UTF-8 string.  Overlong encodings,
 * null characters, invalid Unicode values, and surrogates are
 * accepted.
 */
public static int charLength(byte[] bytes) {
    int charCount = 0, expectedLen;

    for (int i = 0; i &lt; bytes.length; i++) {
        charCount++;
        // Lead byte analysis
        if      ((bytes[i] &amp; 0b10000000) == 0b00000000) continue;
        else if ((bytes[i] &amp; 0b11100000) == 0b11000000) expectedLen = 2;
        else if ((bytes[i] &amp; 0b11110000) == 0b11100000) expectedLen = 3;
        else if ((bytes[i] &amp; 0b11111000) == 0b11110000) expectedLen = 4;
        else if ((bytes[i] &amp; 0b11111100) == 0b11111000) expectedLen = 5;
        else if ((bytes[i] &amp; 0b11111110) == 0b11111100) expectedLen = 6;
        else    return -1;

        // Count trailing bytes
        while (--expectedLen &gt; 0) {
            if (++i &gt;= bytes.length) {
                return -1;
            }
            if ((bytes[i] &amp; 0b11000000) != 0b10000000) {
                return -1;
            }
        }
    }
    return charCount;
}


That's a more versatile function, for about the same amount of code.