我正在尝试学习java但是在处理Scanner类型时我遇到了错误,"无法实例化类型Scanner"。 这是我的代码
import com.sun.java_cup.internal.runtime.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int a = 2;
for (int i = 1; i != 10; i++) {
System.out.println(a + " X " + i + " = " + a * 1);
}
int i = 1;
while (i != 10) {
System.out.printf("%d X %d = %d\n", a + 10, i, (a + 10) * i);
i++;
}
}
}
答案 0 :(得分:9)
您正在从错误的包中导入Scanner
。将导入更改为:
import java.util.Scanner;