• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

delete values from a hastable

 
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello everyone i hope someone can help
i have the code below
which tests if any strings are the same to print them out plus there key values
but now i want to able to delete the values and the key names that have already been used
can anyone help please
thanks
loftty
[ December 09, 2002: Message edited by: Michael Ernest ]
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It you want to remove values from the Hashtable while you're looping through it, use an Iterator rather than an Enumeration (as shown in my other post), and use the remove() method of the Iterator. Otherwise you can use the remove(Object) method of Hashtable, where the argument is the key value to be removed. But don't do this while you're looping through the Hashtable - it confuses things.
[ December 09, 2002: Message edited by: Jim Yingst ]
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jim, I posted a HashMap question below and your response to Ben's post has my attention.
I want to take two hashmaps, iterate through each one and remove the hashmap elements that do not match keys. I was recommended an interfact (Coparable) solution but I am trying to make it simpler. How can I iterate through two hashmaps simultaneously while removing elements that don't match? You mention not removing elements while looping. I don't understand. Please see my post re: data structures.
Ted
 
Jim Yingst
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I replied here.
 
reply
    Bookmark Topic Watch Topic
  • New Topic