I have a set of strings that I'd like to iterate over, and change all of those who equal something, to equal something else:
// Set<String> strings = new HashSet()
for (String str : strings) {
if (str.equals("foo")) {
// how do I change str to equal "bar"?
}
}
I've tried replace() which didn't work. I've also tried removing "str" and adding the desired string, which caused an error. How would I go about doing this?