Posted: Tue Oct 03, 2006 11:50 am Post subject: hidiously stupid question
code:
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?
Sponsor Sponsor
Tony
Posted: Tue Oct 03, 2006 12:22 pm Post subject: (No subject)
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?
Posted: Tue Oct 03, 2006 12:27 pm Post subject: (No subject)
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:
code:
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
Posted: Tue Oct 03, 2006 1:05 pm Post subject: (No subject)
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
Posted: Tue Oct 03, 2006 1:11 pm Post subject: (No subject)
Apparently I can't edit my posts here...so here ya go: