Language: Java

      Scanner in=new Scanner(System.in);
         
        int sumNeeded = in.nextInt();
        int coins=in.nextInt();
         
        ArrayList<Integer> values=new ArrayList<Integer>(coins);
         
         
        for(int i=0;i<coins;i++){
            values.add(in.nextInt());
        }
         
        Collections.sort(values);
         
        int[][] matrix=new int[values.size()+1][sumNeeded+1];
         
         
        for(int i=0;i<matrix.length;i++){
             
            for(int j=0;j<matrix[0].length;j++) {
                 
                if(i==0 || j==0)
                    matrix[i][j]=0;
                else
                    matrix[i][j]=Integer.MAX_VALUE;
            }           
        }
         
 
        for(int i=1; i<matrix.length;i++){
             
            for(int j=1;j<matrix[0].length;j++) {
                                 
                int coinVal=values.get(i-1);
                 
                if(coinVal>j)
                    matrix[i][j]=matrix[i-1][j];
                else
                    matrix[i][j]= Math.min(j/coinVal + matrix[i][j%coinVal], matrix[i][j]);
                 
            }           
        }
         
        System.out.println(matrix[values.size()][sumNeeded]);

Compiler output:
Main.java:1: error: unnamed classes are a preview feature and are disabled by default.
      Scanner in=new Scanner(System.in);
      ^
  (use --enable-preview to enable unnamed classes)
Main.java:9: error: class, interface, enum, or record expected
        for(int i=0;i<coins;i++){
        ^
Main.java:9: error: class, interface, enum, or record expected
        for(int i=0;i<coins;i++){
                    ^
Main.java:9: error: class, interface, enum, or record expected
        for(int i=0;i<coins;i++){
                            ^
Main.java:11: error: class, interface, enum, or record expected
        }
        ^
Main.java:18: error: class, interface, enum, or record expected
        for(int i=0;i<matrix.length;i++){
        ^
Main.java:18: error: class, interface, enum, or record expected
        for(int i=0;i<matrix.length;i++){
                    ^
Main.java:18: error: class, interface, enum, or record expected
        for(int i=0;i<matrix.length;i++){
                                    ^
Main.java:20: error: class, interface, enum, or record expected
            for(int j=0;j<matrix[0].length;j++) {
                        ^
Main.java:20: error: class, interface, enum, or record expected
            for(int j=0;j<matrix[0].length;j++) {
                                           ^
Main.java:24: error: class, interface, enum, or record expected
                else
                ^
Main.java:26: error: class, interface, enum, or record expected
            }           
            ^
Main.java:30: error: class, interface, enum, or record expected
        for(int i=1; i<matrix.length;i++){
                     ^
Main.java:30: error: class, interface, enum, or record expected
        for(int i=1; i<matrix.length;i++){
                                     ^
Main.java:32: error: class, interface, enum, or record expected
            for(int j=1;j<matrix[0].length;j++) {
                        ^
Main.java:32: error: class, interface, enum, or record expected
            for(int j=1;j<matrix[0].length;j++) {
                                           ^
Main.java:36: error: class, interface, enum, or record expected
                if(coinVal>j)
                ^
Main.java:38: error: class, interface, enum, or record expected
                else
                ^
Main.java:41: error: class, interface, enum, or record expected
            }           
            ^
19 errors