Initialize a collection within an object?

后端 未结 10 1267
长发绾君心
长发绾君心 2021-02-04 15:03

If an object has a property that is a collection, should the object create the collection object or make a consumer check for null? I know the consumer should not assume, just

10条回答
  •  猫巷女王i
    2021-02-04 15:41

    I create an empty collection. Sure, it has a slight memory cost, but not a large enough one to be concerned about it.

提交回复
热议问题