Language: Java

class Item {
  int val;
  int weight;
  public Item(int weight, int value) {
    this.val = value;
    this. weight = weight;
  }
}
public class Main {
 
  public static void main(String[]abc) {
     Main answer = new Main();
     long solution = answer.solve();
     System.out.println(solution);
  }
  
  private void solve() {
	Scanner sc = new Scanner(System.in); 
    int N = sc.nextInt();
    int maxWeight = sc.nextInt();
    // max value of an item = 1000
    // total max value = N items * 1000
    int [][] dp = new int[N+1][N*1000];
    long INF = (long) 1e9+1;
    for(int i=0;i<maxValue;i++){
       dp[1][i]= INF;
    }
    Item[] array = new Item[N+1];
    for(int i=1;i<=N;i++){
      array[i]= new Item(sc.nextInt(), sc.nextInt());
    }
    dp[1][item.val] = item.weight;
    dp[1][0]=0;
    for(int i=2;i<=N;i++){
      for(int j=0;j<=maxValue;i++){
        dp[i][j] = dp[i-1][j];
        if (item[i].value>j) continue;
        dp[i][j] = Math.min( dp[i-1][j], dp[i-1][j-item[i].value] + item[i].weight);
      }
    }
    long bestValue =0;
    for(int i=0;i<=maxValue;i++) {
       if (dp[N][i]<maxWeight) bestValue = Math.max(bestValue, dp[N][i]);
    }
    return bestValue;
    
                             
    
  }
  
}

Compiler output:
Main.java:13: error: incompatible types: void cannot be converted to long
     long solution = answer.solve();
                                 ^
Main.java:18: error: cannot find symbol
	Scanner sc = new Scanner(System.in); 
	^
  symbol:   class Scanner
  location: class Main
Main.java:18: error: cannot find symbol
	Scanner sc = new Scanner(System.in); 
	                 ^
  symbol:   class Scanner
  location: class Main
Main.java:25: error: cannot find symbol
    for(int i=0;i<maxValue;i++){
                  ^
  symbol:   variable maxValue
  location: class Main
Main.java:26: error: incompatible types: possible lossy conversion from long to int
       dp[1][i]= INF;
                 ^
Main.java:32: error: cannot find symbol
    dp[1][item.val] = item.weight;
          ^
  symbol:   variable item
  location: class Main
Main.java:32: error: cannot find symbol
    dp[1][item.val] = item.weight;
                      ^
  symbol:   variable item
  location: class Main
Main.java:35: error: cannot find symbol
      for(int j=0;j<=maxValue;i++){
                     ^
  symbol:   variable maxValue
  location: class Main
Main.java:37: error: cannot find symbol
        if (item[i].value>j) continue;
            ^
  symbol:   variable item
  location: class Main
Main.java:38: error: cannot find symbol
        dp[i][j] = Math.min( dp[i-1][j], dp[i-1][j-item[i].value] + item[i].weight);
                                                   ^
  symbol:   variable item
  location: class Main
Main.java:38: error: cannot find symbol
        dp[i][j] = Math.min( dp[i-1][j], dp[i-1][j-item[i].value] + item[i].weight);
                                                                    ^
  symbol:   variable item
  location: class Main
Main.java:42: error: cannot find symbol
    for(int i=0;i<=maxValue;i++) {
                   ^
  symbol:   variable maxValue
  location: class Main
Main.java:45: error: incompatible types: unexpected return value
    return bestValue;
           ^
13 errors