I programmed the following into Eclipse but the program keeps giving me the error: The method put(String, String) is undefined for the type HashMap.As far as I know, put() is the correct method to use to input values into a HashMap. Can anyone please help me debug this problem?
import java.util.HashMap;
public class MapTester
{
public static void main(String[] args)
{
HashMap <String, String>hm = new HashMap <String, String>();
hm.put("type", "56.09");
hm.put("call", "PHONE");
hm.put("what", "PHONE");
System.out.println(hm.toString());
}
}
Thanks.
Try to build and run the program ignoring what eclipse says about it. Does it run? If not, what the compiler outputs? If in doubt try to build it via command-line.
Eclipse (and Netbeans too) may get confused about some things in the code sometimes due to stale caches, incomplete analysis, classpath problems and a lot of other things.