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");
}
}
}
}
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");
}
}
}
}