Why does LinkedHashSet extend HashSet and implement Set

前端 未结 6 721
难免孤独
难免孤独 2020-11-28 08:36

Opened a LinkedHashSet source code today and found some interesting thing:

public class LinkedHashSet
    extends HashSet
    implements Se         


        
6条回答
  •  北海茫月
    2020-11-28 09:33

    Perhaps it has something to do with the way javadoc gets generated. You know how Java API tells you all concrete classes that impement an interface or inherit from other classes? While I agree that at runtime its redundant, I can see how this might ease the automatic generation of javadoc. This is just a wild guess of course.

提交回复
热议问题