This is the code which i wrote.But when i input a word,it should search it and give the definition.I think there is a problem in while loop.But i can't solve it.Can u guys,plz check it?
import java.util.*;
class dictionary
{
public static void main(String args[])
{
Hashtable dict = new Hashtable();
Enumeration names;
String str;
String n;
dict.put("discuss", new String("talk about something"));
dict.put("encourage", new String("persuade to do"));
dict.put("thread", new String("a thing string of cotton"));
// Show all words in hash table.
names = dict.keys();
System.out.println("Enter a word:"+args[0]);
n=args[0];
if(names.equals(n))
{
while(names.equals(n))
{
str = (String)names.nextElement();
System.out.println(str+ ": " +dict.get(str));
}
}
System.out.println();
}
}