Cannot resolve symbol Scanner error

R

Roy Gourgi

Hi,

I am trying to compile this program but I get the error message that it
cannot resolve this symbol Scanner. I downloaded the JDK6 and in my PATH
statement I put C:\Program Files\Java\jdk1.6.0\bin. The code is below. What
am I doing wrong.

TIA
Roy

import java.util.Scanner;

public class GetInteger

{

static Scanner sc = new Scanner(System.in);

public static void main(String[] args)

{

System.out.print("Enter an integer: ");

int i = GetInteger();

System.out.println("You entered "+i);

}

public static int GetInteger()

{

while (true)

{

try

{

return sc.nextInt();

}

catch (InputMismatchException e)

{

sc.next();

System.out.print("Thast not an integer. " + "try again");

}

}

}

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top