my dog learned polymorphism
The moose likes Beginning Java and the fly likes Hash Table Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Hash Table" Watch "Hash Table" New topic

Hash Table

Balaji Ambresh

Joined: Nov 08, 2006
Posts: 7
I am having a hashtable which contains keys of Strings.
Now i want to check whether a string which will be a substring of any
of the keys of the hashtable is present in the hashtable or not.
For example suppose i am having a key like
Now i want to retrieve a table based on whether "firstpart-secondpart" is present as a
substring of any of the keys or not(in this case it is).
one way to do it is calling keys() method of the hashtable and then
looping through all elements of the enumeration and invoking indexOf()
method of String class.
But i do not want a while or for loop.

Is there any other class in Java API which can help me through this ?
marc weber

Joined: Aug 31, 2004
Posts: 11343

Originally posted by Balaji Ambresh:
...But i do not want a while or for loop...

Why not? It sounds like you will need to iterate through an Enumeration (or Set) in some way. What kind of alternative are you looking for?

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
Eric Daly
Ranch Hand

Joined: Jul 11, 2006
Posts: 143
Does java support the "goto" statement? Haha, just kidding. Or what about the do while loop?
[ April 03, 2007: Message edited by: Eric Daly ]

Studying for SCJP 6
I agree. Here's the link:
subject: Hash Table
It's not a secret anymore!