public static void isNested(String arg[]){

        char [] p = { '(','(','(', ')', '(', ')', ')', '(', ')'};
        Stack<Character> openP = new Stack<>();
        boolean malformed;

        int count = 0;

        for(char c : p){

            if(c=='('){
                count++;
                openP.push(c);
            }else if(c==')'){
                count--;
                if(openP.isEmpty()) {
                    System.out.println("the " + count + " char is malformed");
                    malformed = true;
                }

                openP.pop();
            }
        }

        if(!openP.isEmpty()){
            System.out.println("the " + count + " char is malformed");
            malformed = true;
        }

        malformed = false;



        System.out.println("Is malformed "+malformed);
    }