我正在使用 Intellij IDEA。
这是我的代码:
public static void main(String[] args) {
java.util.Scanner scanner = new java.util.Scanner(System.in);
int a = scanner.nextInt();
System.out.println(a);
}
问题是当我运行它时,它起作用了。但是,Intellij 找不到 Scanner 类。它用红色下划线。
如何解决这个问题?
首先,您应该像这样导入扫描仪:
import java.util.Scanner;// in the top!
然后试试这个:
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int a = scan.nextInt();
System.out.println(a);
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)