Everytime I try to run the following Java program it says "No match found for constructor String Tokenizer (java.lang.string)"...What should I do? I dont think the code is wrong itself...
// The "StringTokenizer" class.
import java.io.*;
import java.util.*;
import hsa.Console;
public class StringTokenizer
{
static Console c; // The output console
public static void main (String [] args) throws IOException
{
c = new Console ();
BufferedReader script;
PrintWriter censor;
script = new BufferedReader (new FileReader ("a.txt"));
censor = new PrintWriter (new FileWriter ("b.txt"));
String word;
while (true)
{
String line = script.readLine ();
if (line == null)
break;
StringTokenizer words = new StringTokenizer (line);
while (words.hasMoreTokens ())
{
word = words.nextToken ();
if (word.length () == 4)
{
censor.println (word);
}
}
}
script.close ();
censor.close ();
What to do if a program does not recognize String Tokenizer?
um, you don't have a constructor, like the error says.
The constructor of a class should is a method with the same name as the class and it is called to instantiate an object of that class.
this line: StringTokenizer words = new StringTokenizer (line);
you need to define what StringTokenizer(String s) is.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment