Alternating Characters
No need for stack

You've complicated things by constructing a stack for no reason.  All you need to remember is the last character.  For example:

private static int countChanges(String text) {
    char prev  = 0;
    int  count = 0;

    for (char c : text.toCharArray()) {
        if (c == prev) {
            count++;
        } else {
            prev = c;
        }
    }
    return count;
}


Misleading comment

This comment:


            // top &gt;= 0 or c == chars[top]



should read:

            // top &gt;= 0 and c == chars[top]