Why does LinkedHashSet extend HashSet and implement Set

前端 未结 6 732
难免孤独
难免孤独 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:15

    I've asked Josh Bloch, and he informs me that it was a mistake. He used to think, long ago, that there was some value in it, but he since "saw the light". Clearly JDK maintainers haven't considered this to be worth backing out later.

提交回复
热议问题