我的扫描仪 System.in 有问题

问题描述 投票:0回答:1

我的 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 但问题仍然存在

java eclipse
1个回答
0
投票

因为你的类名为“System”。重命名你的类并且它可以工作。

© www.soinside.com 2019 - 2024. All rights reserved.