• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Hash Table

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
"firstpart-secondpart-thirdpart".
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 ?
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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?
 
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does java support the "goto" statement? Haha, just kidding. Or what about the do while loop?
[ April 03, 2007: Message edited by: Eric Daly ]
 
Rototillers convert rich soil into dirt. Please note that this tiny ad is not a rototiller:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic