I am trying to learn java but While dealing with the Scanner type I ran into the error, "Cannot instantiate the type Scanner". here is my code
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++;
}
}
}
You're importing Scanner
from the wrong package. Change the import to:
import java.util.Scanner;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.