[ajug-members] question from a new coder
Kerry Randolph
kerry at randolph1.com
Thu Dec 4 18:23:18 EST 2008
Hello all
I'm fairly new to Java and not sure how to do this. Any help would be
appreciated.
I'm trying to iterate through a TreeSet and if any String element ends in
"-8000" or "-443" I want to chop that part off.
Here's what I'm trying, but getting a ConcurrentModificationException:
private TreeSet<String> cleanup(TreeSet<String> tSet){
Iterator<String> iter = tSet.iterator();
while(iter.hasNext()){
String s = (String)iter.next();
if(s.endsWith("-8000")){
tSet.remove(s);
s = s.substring(0, s.length()-5);
tSet.add(s);
}
if(s.endsWith("-443")){
tSet.remove(s);
s = s.substring(0, s.length()-5);
tSet.add(s);
}
}
return tSet;
}
Thoughts???? Thanks for the help!!!
--Kerry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.ajug.org/pipermail/ajug-members/attachments/20081204/63bc9ba0/attachment.html
More information about the ajug-members
mailing list