Balance Check in Java
<p>This is code for checking balance symbol.
However, when I try to fit in a Tester,
It does not show the anwer correctly.</p>

<pre><code>import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

public class BalanceCheck {

private static Scanner in;

public static void main(String[] args){
    if(args.length &gt; 0){
        System.out.println(args[0]);
        try {
            in = new Scanner(new File(args[0]));
            MyStack&lt;Character&gt; stack = new MyStack&lt;&gt;();
            String str;
            char ch;
            while(in.hasNext()){
                str = in.next();
                for(int i = 0; i &lt; str.length(); ++i){
                    ch = str.charAt(i);
                    if(ch == '(' || ch == '[' || ch == '{' || 
                            (ch == '/' &amp;&amp; i &lt; str.length() - 1 &amp;&amp; str.charAt(i+1) == '*')){
                        stack.push(ch);
                    }
                    else if(ch == ')'){
                        if(stack.isEmpty() || stack.pop() != ch){
                            System.out.println(") is mismatched");
                            return;
                        }
                    }
                    else if(ch == ']'){
                        if(stack.isEmpty() || stack.pop() != ch){
                            System.out.println("] is mismatched");
                            return;
                        }
                    }
                    else if(ch == '}'){
                        if(stack.isEmpty() || stack.pop() != ch){
                            System.out.println("} is mismatched");
                            return;
                        }
                    }
                    else if(ch == '*' &amp;&amp; i &lt; str.length() - 1 &amp;&amp; str.charAt(i+1) == '/'){
                        if(stack.isEmpty() || stack.pop() != '/'){
                            System.out.println("*/ is mismatched");
                            return;
                        }
                    }
                    else if(ch == '"'){
                        if(stack.isEmpty() || stack.top() == '"'){
                            if(!stack.isEmpty())
                                stack.pop();
                        }
                        else{
                            stack.push(ch);
                        }
                    }
                }
            }
            in.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }
    else{
        System.out.println("Command line argument is not provided..");
    }
}

}
</code></pre>

<p>For instance, if I compile this tester,</p>

<pre><code>/*this tests an unbalanced [ operator*/
public class Test1 {


/* this is the main method */
public static void main(String[ ) args) {
    String ghana = "hello";
    int test = testing();
}

public int testing() {
    /*checking this too */
    /* and this */ 
    return 1; 
}


}
</code></pre>

<p>It should show [ is mismatched. But, it shows /* is mismatched.</p>

<p>Please let me know solution.</p>

<p>And I have to create a Tester file for this code above.</p>

<p>How can I code a tester for this?</p>

<p>Thanks,                         </p>