File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to get values in hashtable

 
vin Hari
Ranch Hand
Posts: 162
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,
Iam using hashtable for my program through which i can fetch keys using
Hashtable(name).key()

but i wnat to fetch values how to do please if any functions are there please tell me.
thanks in advance
 
Qunfeng Wang
Ranch Hand
Posts: 434
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Amit Arora
Ranch Hand
Posts: 30
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For fetching all the values from hash table in a set use:

Set set = ht.values()

where ht is object of Hashtable

but to get a value corresponding to a key use

Object o = ht.get("key");

and down cast it to required object
 
Muhammad Saifuddin
Ranch Hand
Posts: 1324
Android Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the link will guide you more on that.. http://java.sun.com/developer/TechTips/1998/tt0316.html#tip2

Suggestion: best place to ask this question in Java in General forum.
 
Rob Spoor
Sheriff
Pie
Posts: 20396
47
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Amit Arora:
For fetching all the values from hash table in a set use:
Set set = ht.values()

That should be Collection c = ht.values();

values() returns a collection, it's keySet() and entrySet() that return Sets.
 
Amit Arora
Ranch Hand
Posts: 30
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes that is collection returned by values method.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic