user2669743
user2669743

Reputation: 13

Cannot find Scanner Class

import util.java.Scanner;

class Anagram    
{

public static void main(String args[])
 {
  String s1=new String();

  Scanner s=new Scanner(System.in);
  s1=s.nextLine();             
 }
}

This gives error :

cannot find symbol Scanner....

whats wrong here?

Upvotes: 0

Views: 130

Answers (3)

Ruchira Gayan Ranaweera
Ruchira Gayan Ranaweera

Reputation: 35557

Scanner class in java.util.Scanner package. Import you are using here is incorrect. I suggest you to use IDE to do coding since this kind of issues easily identify by then.

Upvotes: 0

Obicere
Obicere

Reputation: 3019

The import you have is wrong.

It should be:

import java.util.Scanner;

instead of

import util.java.Scanner;

Upvotes: 3

Prasad Kharkar
Prasad Kharkar

Reputation: 13556

The correct import statement is java.util.Scanner. For avoiding these kind of errors, its good to use and IDE.

Upvotes: 4

Related Questions