Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 hidiously stupid question
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Tubs




PostPosted: 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
Sponsor
sponsor
Tony




PostPosted: 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?
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Tubs




PostPosted: 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




PostPosted: 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




PostPosted: Tue Oct 03, 2006 1:11 pm   Post subject: (No subject)

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... Rolling Eyes
http://www.google.ca/search?hl=en&q=Scanner+class+library+%2BJava&btnG=Search&meta=
[Gandalf]




PostPosted: Tue Oct 03, 2006 4:30 pm   Post subject: (No subject)

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.
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 6 Posts ]
Jump to:   


Style:  
Search: