Language: Java

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Arrays;

public class Main {

    private static Scanner sc;

    public static void main(String[] args) {
        Main instance = new Main();
        instance.solve();
    }

    private void solve() {
        try {
            boolean[] numbers = new boolean[10];

            int n = sc.nextInt();
            int k = sc.nextInt();

            for (int i = 0; i < 10; i++) {
              numbers[i] = true;
            }
            for (int i = 0; i < k; i++) {
              int d = sc.nextInt();
              numbers[d] = false;
            }

            while (true) {
              String number = String.valueOf(n.charAt(i));
              boolean isValid = true;
              for (int j = 0; j < n.length(); j++) {
                if (numbers[Integer.parseInt(number)] == false) {
                  isValid = false;
                  break;
                }
              }
              if (isValid) {
                break;
              }
              n++;  
            }

            System.out.println(n);

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private class Scanner {
        String[] s;
        int i;
        BufferedReader br;
        String regex = " ";

        public Scanner() {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        @Override
        protected void finalize() throws Throwable {
            try {
                super.finalize();
            } finally {
                destruction();
            }
        }

        private void destruction() throws IOException {
            if (br != null) br.close();
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String st = br.readLine();
            while (st == "") st = br.readLine();
            s = st.split(regex, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public Long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }

        public Double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }
    }
}


Compiler output:
Main.java:34: error: cannot find symbol
              String number = String.valueOf(n.charAt(i));
                                                      ^
  symbol:   variable i
  location: class Main
Main.java:34: error: int cannot be dereferenced
              String number = String.valueOf(n.charAt(i));
                                              ^
Main.java:36: error: int cannot be dereferenced
              for (int j = 0; j < n.length(); j++) {
                                   ^
Main.java:68: warning: [removal] finalize() in Object has been deprecated and marked for removal
        protected void finalize() throws Throwable {
                       ^
Main.java:70: warning: [removal] finalize() in Object has been deprecated and marked for removal
                super.finalize();
                     ^
3 errors
2 warnings