Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

New to Java getting error "Scanner cannot be resolved.."

Status
Not open for further replies.

Enea

Technical User
Feb 23, 2005
90
US
New to Java. Following exercise #1 of a Java book.

Code is the following:

import java.util.*;

public class FirstProject
{
public static void main(String[] args)
{
System.out.println("Hello out there.");
System.out.println("I will add two numbers for you.");
System.out.println("Enter two whole numbers on a line:");

int n1, n2;

Scanner keyboard = new Scanner(System.in);
n1 = keyboard.nextInt( );
n2 = keyboard.nextInt( );

System.out.println("The sum of those two numbers is");
System.out.println(n1 + n2);
}
}


Error is:
Scanner cannot be resolved or is not a type
The import java.util is never used

Today I went to the following link:


and downloaded jdk-1_5_0_06-windows-i586-p-iftw.exe
I installed it but I am still getting the same error.

What do I need to do to solve the problem?

Thank you,

En..
 
Please do not cross-post across forums on this website - its is very annoying for people replying.

This forum, also, is meant for J2EE questions - standard Java questions should only be posted in forum269 (where you have cross-posted)

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top