IntelliJ cannot find scanner class

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 the Scanner class. It emphasizes the red color.

How to fix it?

+6
source share
1 answer

First you must import the scanner as follows:

 import java.util.Scanner;// in the top! 

and then try the following:

 public static void main(String[] args) { Scanner scan = new Scanner(System.in); int a = scan.nextInt(); System.out.println(a); } 
+1
source

Source: https://habr.com/ru/post/977619/


All Articles