Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    Senior Coder twodayslate's Avatar
    Join Date
    Mar 2007
    Location
    VA
    Posts
    1,042
    Thanks
    67
    Thanked 39 Times in 39 Posts

    Scanner cannot be resolved to a type

    Just installed eclipse having not been programming for a month...
    Code:
    import java.util.*;
    public class twod {
    	public static void  main(String[] args) 
    	{
    		Scanner in = new Scanner(System.in);
    		System.out.println("How many rows?");
    		int rows = in.nextInt();
    		System.out.println("How many columns?");
    		int columns = in.nextInt();
    		double[][] table = new double[rows][columns];
    		
    		double input;
    	
    		for(int r = 0; r < rows; r++)
    		{
    			for(int c = 0; c < columns; c++)
    			{
    				System.out.println(r + "," + c + " :");
    				input = in.nextDouble();
    				table[r][c] = input;
    			}
    		}
    	
    		for(double[] e : table)
    		{
    			System.out.print(e);
    		}
    		}//end main
    }//end
    error:
    Code:
    Exception in thread "main" java.lang.Error: Unresolved compilation problems: 
    	Scanner cannot be resolved to a type
    	Scanner cannot be resolved to a type
    
       at twod.main(twod.java:5)
    Code:
    ~$ java -version
    java version "1.6.0_06"
    Java(TM) SE Runtime Environment (build 1.6.0_06-b02)
    Java HotSpot(TM) Client VM (build 10.0-b22, mixed mode, sharing)
    I hope I did the 2D arrays right.
    Last edited by twodayslate; 08-03-2008 at 03:12 AM.
    twitter | Quality Hosting - $5.95/mo*
    Feel free to PM me!


 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •