我的 Eclipse 项目有问题,我正在使用扫描仪,但错误日志告诉我 System.in 中的“in”无法解析或不在字段中。这是我的代码:
import java.lang.*;
import java.util.Scanner;
public class System {
public static void main(String [] args)
{
Scanner sc = new Scanner(System.in);
System.out.println("Please enter an integer");
int i = sc.nextInt();
System.out.println(i);
}
}
这是我的错误:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
in cannot be resolved or is not a field
out cannot be resolved or is not a field
out cannot be resolved or is not a field
我尝试更新并重新安装我的 eclipse 但问题仍然存在
因为你的类名为“System”。重命名你的类并且它可以工作。