
-----------------------------------
Tubs
Tue Oct 03, 2006 11:50 am

hidiously stupid question
-----------------------------------
package veen1710;

import java.util.Scanner;

public class Begin {

	public static void main(String[] args) {

		System.out.println("Enter the target equation:");
		Scanner s = new Scanner( System.in );
		
		Tokenizer t = new Tokenizer(s);
			
		while (t.hasMoreTokens()) {
		    System.out.println(t.nextToken());
			
    	}

	}

}

I am getting an error that Scanner cannot be resolved into a type and import java.util.Scanner cannot be resolved into a type. Very new at java so I don't know what could be wrong here... any ideas?

-----------------------------------
Tony
Tue Oct 03, 2006 12:22 pm


-----------------------------------
Scanner does not resolve to a type, because of your next error - the import statement doesn't execute. I'm not sure as to why.

What is this package thing, and why do you have it there?

-----------------------------------
Tubs
Tue Oct 03, 2006 12:27 pm


-----------------------------------
It is the package that contains all the classes with my school login name. This was the code that I used in lab and it worked fine:

package xxxxnnnn; (use your login as a package name)

import java.util.Scanner;

class ScannerTest
{
    public static void main( String args[] )
    {
        System.out.println("Enter a series of integers. Press 'q' to quit.");
        // Read from the keyboard.
        Scanner s = new Scanner( System.in );
        int result = 0;
        
        while( s.hasNextInt())
        {
          result += s.nextInt();                      
        }
        
        s.close();
        System.out.println("The total is " + result);  
    }
}


-----------------------------------
r.3volved
Tue Oct 03, 2006 1:05 pm


-----------------------------------
Sounds like you probably don't have that scanner library installed, or your interpreter is not setup to link to that library yet

-----------------------------------
r.3volved
Tue Oct 03, 2006 1:11 pm


-----------------------------------
Apparently I can't edit my posts here...so here ya go:

http://forum.java.sun.com/thread.jspa?threadID=737355&messageID=4251558

btw that was the first google search I tried and it was the first link returned... :roll: 
http://www.google.ca/search?hl=en&q=Scanner+class+library+%2BJava&btnG=Search&meta=

-----------------------------------
[Gandalf]
Tue Oct 03, 2006 4:30 pm


-----------------------------------
To me it sounds like you don't have Java 1.5.0 installed.  Check which version of Java you have... Only 1.5 has the Scanner class.
