Language: Java

static boolean check(String s) {
        Stack<Character> stack = new Stack<>(); //
        for(int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if(c == ‘.’) {
                break;
            }
            if(c == ‘(’) {
                stack.push(‘)’);
            }
            if(c == ‘[’) {
                stack.push(‘]’);
            }
            if(c == ‘)’ || c == ‘]’) {
                if(stack.isEmpty() || stack.pop() != c) {
                    return false;
                }
            }
        }
        return stack.isEmpty();
    }

    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            while(sc.hasNextLine()){
                String s = sc.nextLine();
                if(s.equals(“.”)) {
                    break;
                }
                if(check(s)) {
                    System.out.println(“yes”);
                }
                else {
                    System.out.println(“no”);
                }
            }
        }
    }


Compiler output:
Main.java:5: error: illegal character: '\u2018'
            if(c == ?.?) {
                    ^
Main.java:5: error: illegal character: '\u2019'
            if(c == ?.?) {
                      ^
Main.java:8: error: illegal character: '\u2018'
            if(c == ?(?) {
                    ^
Main.java:8: error: illegal character: '\u2019'
            if(c == ?(?) {
                      ^
Main.java:9: error: illegal character: '\u2018'
                stack.push(?)?);
                           ^
Main.java:9: error: illegal character: '\u2019'
                stack.push(?)?);
                             ^
Main.java:11: error: illegal character: '\u2018'
            if(c == ?[?) {
                    ^
Main.java:11: error: illegal character: '\u2019'
            if(c == ?[?) {
                      ^
Main.java:12: error: illegal character: '\u2018'
                stack.push(?]?);
                           ^
Main.java:12: error: illegal character: '\u2019'
                stack.push(?]?);
                             ^
Main.java:14: error: illegal character: '\u2018'
            if(c == ?)? || c == ?]?) {
                    ^
Main.java:14: error: illegal character: '\u2019'
            if(c == ?)? || c == ?]?) {
                      ^
Main.java:14: error: illegal character: '\u2018'
            if(c == ?)? || c == ?]?) {
                                ^
Main.java:14: error: not a statement
            if(c == ?)? || c == ?]?) {
                             ^
Main.java:14: error: illegal character: '\u2019'
            if(c == ?)? || c == ?]?) {
                                  ^
Main.java:1: error: unnamed classes are a preview feature and are disabled by default.
static boolean check(String s) {
       ^
  (use --enable-preview to enable unnamed classes)
Main.java:27: error: illegal character: '\u201c'
                if(s.equals(?.?)) {
                            ^
Main.java:27: error: illegal character: '\u201d'
                if(s.equals(?.?)) {
                              ^
Main.java:31: error: illegal character: '\u201c'
                    System.out.println(?yes?);
                                       ^
Main.java:31: error: illegal character: '\u201d'
                    System.out.println(?yes?);
                                           ^
Main.java:31: error: not a statement
                    System.out.println(?yes?);
                                        ^
Main.java:34: error: illegal character: '\u201c'
                    System.out.println(?no?);
                                       ^
Main.java:34: error: illegal character: '\u201d'
                    System.out.println(?no?);
                                          ^
Main.java:34: error: not a statement
                    System.out.println(?no?);
                                        ^
24 errors