Intellij Can't Find Scanner Class [Duplicate]
I Am Using Intellij Idea. Here Is My Code: Public Static Void Main(String[] Args) { Java. Util. Scanner Scanner = New Java. Util. Scanner(System. In); Int a =...
I am using Intellij IDEA.
Here is my code:
public static void main(String[] args) {
java.util.Scanner scanner = new java.util.Scanner(System.in);
int a = scanner.nextInt();
System.out.println(a);
}
The problem is that when I run it, it works. But, Intellij cannot find Scanner class. It is underlining with red color.
How to fix this?
First you should import the Scanner like this:
import java.util.Scanner;// in the top!
and then try this:
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int a = scan.nextInt();
System.out.println(a);
}
Right click on code editor window and click on run.