Check for balanced parentheses Given an expression string exp, write a program to examine whether the
  pairs and the orders of

"{","}","(",")","[","]"

  
  are correct in exp.
  
  For example, the program should print true for

exp = "[()]{}{[()()]()}"

  
  and false for

exp = "[(])"



Complexity:


Time complexity: O(n) where n is length of the string
Space complexity: O(n/2) where n is length of string 


Looking for code review, optimizations and best practices. 

public final class BalancedParanthesis {

    private static final Map&lt;Character, Character&gt; brackets = new HashMap&lt;Character, Character&gt;();
    static {
        brackets.put('[', ']');
        brackets.put('{', '}');
        brackets.put('(', ')');
    }  

    private BalancedParanthesis() {};

    /**
     * Returns true is parenthesis match open and close.
     * Understands [], {}, () as the brackets
     * It is clients responsibility to include only valid paranthesis as input.
     * A false could indicate that either parenthesis did not match or input including chars other than valid paranthesis
     * 
     * @param str   the input brackets
     * @return      true if paranthesis match.
     */
    public static boolean isBalanced(String str) {
        if (str.length() == 0) {
            throw new IllegalArgumentException("String length should be greater than 0");
        }
        // odd number would always result in false
        if ((str.length() % 2) != 0) {
            return false;
        }

        final Stack&lt;Character&gt; stack = new Stack&lt;Character&gt;();
        for (int i = 0; i &lt; str.length(); i++) {
            if (brackets.containsKey(str.charAt(i))) {
                stack.push(str.charAt(i));
            } else if (stack.empty() || (str.charAt(i) != brackets.get(stack.pop()))) {
                return false;
            } 
        }
        return true;
    } 

    public static void main(String[] args) {
        assertEquals(true, isBalanced("{}([])"));
        assertEquals(false,isBalanced("([}])"));
        assertEquals(true, isBalanced("([])"));
        assertEquals(true, isBalanced("()[]{}[][]"));
    }
}
I just wanted to write that the code looks completely fine to me, until...
assertEquals(false, isBalanced(&quot;[[&quot;));

I''m sure you'll find the error :-)
Otherwise two small remarks:

Personally I'd have the function return true for an empty string instead of throwing an exception.

Stack is outdated. I'd use a Deque implementation instead.


EDIT: I'm sorry, but I just realized something else: Your program doesn't fulfill the requirement O(n/2) for space complexity.