Is it better to use List or Collection?

前端 未结 8 695
失恋的感觉
失恋的感觉 2021-02-03 19:33

I have an object that stores some data in a list. The implementation could change later, and I don\'t want to expose the internal implementation to the end user. However, the us

8条回答
  •  闹比i
    闹比i (楼主)
    2021-02-03 20:38

    It just depends, do you want your users to be able to index into the data? If yes, use List. Both are interfaces, so you're not leaking implementation details, really, you just need to decide the minimum functionality needed.

提交回复
热议问题