File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Hashtable ???? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Hashtable ????" Watch "Hashtable ????" New topic
Author

Hashtable ????

Deepika Wadhwa
Ranch Hand

Joined: Aug 05, 2000
Posts: 57
Hi all ,
i just want to know that how can i check my Hashtable whether it contains a value greater than "0".
is there any way do it ???

thanx in advance
Deepika


------------------
jason adam
Chicken Farmer ()
Ranch Hand

Joined: May 08, 2001
Posts: 1932
Depending on what you want to do, there are a couple of options. If by 0 you mean that the hashtable has been created, but nothing is in there, you can do a Hashtable.isEmpty(), which returns true if there is nothing in the hashtable, or false if there is.
You can also use Hashtable.size(), which returns the number of keys in your hashtable. This way, if you want to know that there are more than 0, or more than 1, or whatever, you can test for that.
Hope that helps
Jason
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1506
If you want to check it's contents for a value > 0, then you have to enumerate thru the collection, checking/retrieving, and converting to an int, if need be, each element if it's greater than zero.

Bosun


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
jason adam
Chicken Farmer ()
Ranch Hand

Joined: May 08, 2001
Posts: 1932
Wait, are you wanting to know if your Hashtable contains a number that is greater than 0, or if your Hashtable contains more than 0 elements?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hashtable ????
 
Similar Threads
Hashtable casting error
Reg: HashMap
Collections.synchronizedMap or thread safe classes in collection which one is better?
I defined an equals method, but Hashtable ignores it. Why?
Passing my object to one to other activity