0
package java_learning;

public class main {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
    
        System.out.println("what is your name?");
        String name = scanner.nextLine();
        
        System.out.println("hello"+name);
        
        
                
    }

}

the error is Exception in thread "main" java.lang.Error: Unresolved compilation problems: Scanner cannot be resolved to a type scanner cannot be resolved to a type

at java_learning.main.main(main.java:7)
Mnfari
  • 11
  • 3

4 Answers4

4

First of all import the package

import java.util.Scanner

Then just change the new scanner() to new Scanner()

Final code :

package java_learning;

import java.util.Scanner;

public class main {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
    
        System.out.println("what is your name?");
        String name = scanner.nextLine();
        
        System.out.println("hello"+name);
        
        
                
    }

}
Rohith V
  • 1,089
  • 1
  • 9
  • 23
2

You got an typo in this line:

Scanner scanner = new scanner(System.in);

It needs to be:

Scanner scanner = new Scanner(System.in);
KreutzerCode
  • 334
  • 1
  • 2
  • 12
0

Import this , import java.util.scanner; and the s in the new scanner is small, make it Big "S"

Xm Par
  • 83
  • 1
  • 8
0

You need to import this library as import java.util.Scanner; and update new scanner line as new Scanner()