posted 16 years ago
Well, a Map or Set assumes that the keys (for Map) or values (for Set) will not change. And the entire purpose of a StringBuffer is to change its content. Which makes them extremely poor choices to use in a Map or Set - if you change the content of a StringBuffer after you use it as a key in a Map, the map won't work correctly. There are two basic options:
1. If you're dong changing the content of the StringBuffer, use toString() to convert it to an immutable String, and use the String as the key in your Map.
2. If you're not done changing the content of the StringBuffer, don't even try to use it as a key in a Map. It will only cause you pain.
"I'm not back." - Bill Harding, Twister