说我public static void main(String[] args)有问题

显示的问题是这样的

Exception in thread "main" java.lang.Error: Unresolved compilation problem: 

        at Lab1.main(lab1.java:4)

这是我的代码

import java.util.Scanner;

public class Lab1{

 

  public static void main(String[] args) {

  Scanner a = new Scanner(System.in);

  int size1 = a.nextInt();

  int [] answer1 = new int[size1];

  for(int i = 0 ; i < size1; i++){

  answer1[i] = a.nextInt();

  }

 

  Scanner b = new Scanner(System.in);

  int size2 = b.nextInt();

  int [] answer2 = new int[size2];

  for(int j = 0 ; j < size2; j++){

  answer2[j] = b.nextInt();

 

  }

 

  

  Set set1 = new Set();

  Set set2 = new Set();

 

  for(int i = 0 ; i < answer1.length;i++)

  set1.add(answer1[i]);

  for(int j = 0 ; j < answer2.length;j++)

  set2.add(answer2[j]);

  

  if(set1.compare(set2))

  System.out.println("The sets are equal!");

  else

  System.out.println("The sets are different!");

  } 

}

class Set {

  private int[] data;

  private int size;

 

  public Set() {

    data = new int[20];

    size = 0;

  }

 

  public void add(int value) {

    int[] copy;

    if (!in(value)) {

      if (size >= data.length) {

        // Resize the array

        copy = new int[data.length * 2];

        System.arraycopy(data, 0, copy, 0, data.length);

        data = copy;

      }

      data[size] = value;

      size++;

    }

  }

 

  public boolean in(int value) {

    for (int i = 0; i < size; i++) {

      if (data[i] == value)

        return true;

    }

    return false;

  }

 

  public Set intersection(Set other) {

    Set result = new Set();

    for (int i = 0; i < size; i++) {

      if (other.in(data[i]))

        result.add(data[i]);

    }

    return result;

  }

 

  public Set union(Set other) {

    Set result = (Set)other.clone();

    for (int i = 0; i < size; i++) {

      result.add(data[i]);

    }

    return result;

  }

 

  public Object clone() {

    Set result = new Set();

    for (int i = 0; i < size; i++) {

      result.add(data[i]);

    }

    return result;

  }

 

  public String toString() {

    String result = "{";

    for (int i = 0; i < size; i++) {

      result += " " + data[i];

      // Add a comma after all but the last item

      if (i < size - 1)

        result += ",";

    }

    result += " }";

    return result;

  }


 

    public boolean compare( Set other){

    boolean check = true;//in(data[i])   this.in(data[i])

    for(int i = 0 ; i < size; i++){

      check = other.in(this.data[i]);

      if(!check)

      return check;

    }

      return check;

    }

  }


 

  

  

把你的jdk换一下,你这项目jdk不对

参考这篇文章:https://blog.csdn.net/Anduin_/article/details/84102362

public class ClassTest {
    public static void main(String[] args) {
        System.out.println("测试");
    }
}
你写一个最基本的main方法运行看是否报错。如果不报错,把你报错的那个类代码复制到这个类中。

 

经测试,程序正常,应该是jdk环境问题。

您好,我是有问必答小助手,您的问题已经有小伙伴解答了,您看下是否解决,可以追评进行沟通哦~

如果有您比较满意的答案 / 帮您提供解决思路的答案,可以点击【采纳】按钮,给回答的小伙伴一些鼓励哦~~

ps:问答VIP仅需29元,即可享受5次/月 有问必答服务,了解详情>>>https://vip.csdn.net/askvip?utm_source=1146287632