Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

hashmap..what's wrong with this simple class..?

Status
Not open for further replies.

patnim17

Programmer
Jun 19, 2005
111
US
Hi,
I get a NullPointerException when I run this ...what am I doing wrong?

import java.util.*;
class HashMapDC{
private HashMap hmp;
public void HashMapDC(){ hmp = new HashMap();}
public void sethmp(String s1,String s2){
hmp.put(s1,s2);
}
}
public class TestHashMap{
public static void main(String args[]){
HashMapDC hmpdc = new HashMapDC();
hmpdc.sethmp("1","One");

}
}


thanks,
nims.
 
Sorry...got it...made the constructor return void..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top