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

后端 未结 11 2273
暖寄归人
暖寄归人 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条回答
  •  旧时难觅i
    2020-12-07 19:18

    HashSet is a little bit simplier than HashMap. If you don't need the features of HashMap, why use it? If the method like getObject(ObjectType o) was implemented by Java we dont need to iterate over the set after calling contain() methode...

提交回复
热议问题