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

delete values from a hastable

 
ben riches
Ranch Hand
Posts: 126
  • 0
  • Mark post as helpful
  • send pies
  • 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 ]
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • 0
  • Mark post as helpful
  • send pies
  • 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 ]
 
Ted Striker
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • 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
Sheriff
Posts: 18671
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I replied here.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic