Effective Java By Joshua Bloch: Item1 - Static Factory Method

后端 未结 6 640
猫巷女王i
猫巷女王i 2020-12-13 05:20

I am reading the Effective Java by Joshua Bloch and I have question about Item1 Static Factory Method.

Quote[Bloch, p.7]<

6条回答
  •  北荒
    北荒 (楼主)
    2020-12-13 05:41

    It simply means that the return type of the static factory methods in Collections (and other classes like it) are interface types (e.g. List) rather than specific implementation classes (e.g. java.util.Collections.UnmodifiableList), which are not visible to users since that would just complicate things and increase the size of the API.

提交回复
热议问题