public boolean analyze(String str){
        if(!stack.isEmpty()){
            stack = new Stack(stackSize);
        }
        for (int i = 0; i < str.length(); i++){
            if (str.charAt(i) == '('){
                stack.push('(');
            }
            if (str.charAt(i) == ')')
            {
                if (stack.isEmpty()){
                    System.out.print("Invalid balance (close bracket without open bracket)");
                    return false;
                }
                else {
                    stack.pop();
                }
            }
        }
        if (!stack.isEmpty()){
            System.out.print("Invalid balance (open bracket without close bracket)");
            return false;
        }
        return true;
    }