Java: Set interface and Collection interface differences

前端 未结 4 2148
时光取名叫无心
时光取名叫无心 2021-02-12 10:43

I just looked up the Set interface and found that it mostly (or completely) only redeclares functions which are already in the Collection interface.

4条回答
  •  自闭症患者
    2021-02-12 10:57

    The answer is in the java6 API for set.

    "The Set interface places additional stipulations, beyond those inherited from the Collection interface, on the contracts of all constructors and on the contracts of the add, equals and hashCode methods. Declarations for other inherited methods are also included here for convenience. (The specifications accompanying these declarations have been tailored to the Set interface, but they do not contain any additional stipulations.)"

提交回复
热议问题