Ok so here is my issue. I have to HashSet
's, I use the removeAll
method to delete values that exist in one set from the other.
Prior to calling the method, I obviously add the values to the Set
s. I call .toUpperCase()
on each String
before adding because the values are of different cases in both lists. There is no rhyme or reason to the case.
Once I call removeAll
, I need to have the original cases back for the values that are left in the Set
. Is there an efficient way of doing this without running through the original list and using CompareToIgnoreCase
?
Example:
List1:
"BOB"
"Joe"
"john"
"MARK"
"dave"
"Bill"
List2:
"JOE"
"MARK"
"DAVE"
After this, create a separate HashSet
for each List using toUpperCase()
on String
s. Then call removeAll
.
Set1.removeAll(set2);
Set1:
"BOB"
"JOHN"
"BILL"
I need to get the list to look like this again:
"BOB"
"john"
"Bill"
Any ideas would be much appreciated. I know it is poor, there should be a standard for the original list but that is not for me to decide.