Why doesn't java.util.HashSet have a get(Object o) method?

后端 未结 11 2279
暖寄归人
暖寄归人 2020-12-07 18:39

I\'ve seen other questions about getting objects from Set\'s based on index value and I understand why that is not possible. But I haven\'t been able to find a

11条回答
  •  被撕碎了的回忆
    2020-12-07 19:01

    A common use case of a get method on Set might be to implement an intern set. If that's what you're trying to achieve, consider using the Interner interface and Interners factory from Google Guava.

提交回复
热议问题