I created a class HashString that extends Hashtable and implements Map. HashString class is suppose to read all the words/strings from a file and store the unique value in Hashtable.
in my main method I have the following:
public static void main( String [ ] args )
{
HashString word = new HashString(initialCapacity);
System.out.println( "Checking... (no more output means success)" );
try {
BufferedReader in = new BufferedReader(new FileReadeR("venusandadonis");
String l,w;
StringTokenizer str;
while ((l = in.readLine()) != null)
{
str = new StringTokenizer(l);
while (str.hasMoreTokens()) {
w = str.nextToken();
if (!(word.containsValue(w)) && word.isEmpty())
word.put(initHash(w), new String (w));
else
{ while(!(word.isEmpty()) && word.containsValue(w))
word.put(probeHash(w), new String(w));
}
}
}
}catch(Exception e) { System.err.println("error" }
}
where initHash produces a hash function and probeHash probes the hashtable quadratically.
I get the following compilation error:
method put(int, java.lang.String) not found in class HashString
From what I understand, method put(key, value) is already defined in class Hashtable. And HashString is extending it so therefore HashString should inherit the put(x,y) method. Am I missing something??? I've tried using array initially for my hashtable, didn't work. Then I discovered yesterday about Hashtable class, so I'm hoping it'll work this time. Any help would be GREATLY appreciated.
Thanks in advance.
in my main method I have the following:
public static void main( String [ ] args )
{
HashString word = new HashString(initialCapacity);
System.out.println( "Checking... (no more output means success)" );
try {
BufferedReader in = new BufferedReader(new FileReadeR("venusandadonis");
String l,w;
StringTokenizer str;
while ((l = in.readLine()) != null)
{
str = new StringTokenizer(l);
while (str.hasMoreTokens()) {
w = str.nextToken();
if (!(word.containsValue(w)) && word.isEmpty())
word.put(initHash(w), new String (w));
else
{ while(!(word.isEmpty()) && word.containsValue(w))
word.put(probeHash(w), new String(w));
}
}
}
}catch(Exception e) { System.err.println("error" }
}
where initHash produces a hash function and probeHash probes the hashtable quadratically.
I get the following compilation error:
method put(int, java.lang.String) not found in class HashString
From what I understand, method put(key, value) is already defined in class Hashtable. And HashString is extending it so therefore HashString should inherit the put(x,y) method. Am I missing something??? I've tried using array initially for my hashtable, didn't work. Then I discovered yesterday about Hashtable class, so I'm hoping it'll work this time. Any help would be GREATLY appreciated.
Thanks in advance.