Results 1 to 5 of 5
Thread: Hash
- 04-17-2009, 07:08 AM #1
Member
- Join Date
- Apr 2009
- Posts
- 7
- Rep Power
- 0
- 04-17-2009, 07:31 AM #2
Hashtable will not allow us to store null value.
If u want to store string a value use "" instead of null
- 04-17-2009, 07:36 AM #3
code sample
use HashMap if u want to store null values .for 2 keys I have stored null and try to retreive as what u said.
import java.util.HashMap;
class Sample
{
public static void main(String[] args) throws Exception
{
HashMap ht = new HashMap();
ht.put("1",null);
ht.put("2","test1");
ht.put("3",null);
String name=ht.containsKey("3")?(String)ht.get("3"):"null ";
System.out.println(name);
}//main
}//Sample
- 04-17-2009, 08:18 AM #4
Member
- Join Date
- Apr 2009
- Posts
- 7
- Rep Power
- 0
This code for everything it prints null.
I want something like ht.put("3","");Java Code:import java.util.HashMap; class Sample { public static void main(String[] args) throws Exception { HashMap ht = new HashMap(); ht.put("1",null); ht.put("2","test1"); ht.put("3",null); String name=ht.containsKey("2")?(String)ht.get("2"):"null"; System.out.println(name); }//main }//Sample
I mean after the value 3 if there is no character's and if it is a blank space
This gives run time error.Last edited by sandy1028; 04-17-2009 at 08:21 AM.
- 04-17-2009, 10:36 AM #5
Similar Threads
-
Hash Map
By rekha in forum New To JavaReplies: 1Last Post: 03-21-2009, 01:00 PM -
I need a 32 or 64 bit hash function
By fogus in forum New To JavaReplies: 12Last Post: 03-18-2009, 02:52 AM -
Hash Values ???
By MuslimCoder in forum New To JavaReplies: 6Last Post: 01-16-2009, 04:26 AM -
Hash Table Help
By michael_mke in forum New To JavaReplies: 3Last Post: 11-27-2008, 05:12 PM -
Hash Table help
By rhm54 in forum New To JavaReplies: 0Last Post: 02-08-2008, 01:25 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks