Scanner (read in) problem. P;ease HELP


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Scanner (read in) problem. P;ease HELP

  1. #1
    Join Date
    Dec 2005
    Posts
    1

    Scanner (read in) problem. P;ease HELP

    Hi all

    i am using netbeans 4.1 and JCreator.

    my problem is that i wish to read in from the keyboard but i get errors.

    import java.io.*;
    import java.lang.*;
    import java.util.*;

    class Hospital{


    public static void main (String[] args){



    int num;
    Scanner sc = new Scanner(System.in);


    System.out.println("**********HOPSPITAL**********\n\n");
    System.out.println("Please choose the correct number");
    num = sc.next ();

    The error i get is:

    --------------------Configuration: <Default>--------------------
    C:\Hospital.java:14: cannot resolve symbol
    symbol : class Scanner
    location: class Hospital
    Scanner sc = new Scanner(System.in);
    ^
    C:\Hospital.java:14: cannot resolve symbol
    symbol : class Scanner
    location: class Hospital
    Scanner sc = new Scanner(System.in);
    ^
    2 errors

    Process completed.

    Please Help

  2. #2
    Join Date
    Dec 2004
    Location
    San Bernardino County, California
    Posts
    1,468
    You have not imported the Scanner class into your project. This class was added by Java 1.5. It sounds as if you are not running this version of the jdk.
    Last edited by nspils; 12-04-2005 at 01:00 PM.

Similar Threads

  1. How to read objects from file in a loop
    By mail2vinaybabu in forum Java
    Replies: 10
    Last Post: 02-27-2005, 02:07 PM
  2. Replies: 1
    Last Post: 02-26-2005, 10:50 AM
  3. Replies: 0
    Last Post: 08-09-2003, 03:04 AM
  4. Reliability Problem
    By elise in forum Java
    Replies: 0
    Last Post: 10-30-2002, 05:40 AM
  5. JAVA read file problem
    By VAX in forum Java
    Replies: 1
    Last Post: 06-06-2001, 11:57 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center