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

Forum statistics

Threads
474,262
Messages
2,571,048
Members
48,769
Latest member
Clifft

Latest Threads

Top