Best string container: StringCollection, Collection, List, ArrayList, ..?

后端 未结 2 1037
春和景丽
春和景丽 2020-12-08 09:58

What is the most suitable container just for strings holding in some array with non-predetermined upper boundary, which length is unknown on it\'s creation.

For simp

2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-08 10:23

    A List would be the most efficient.

    The Collection class is just a wrapper for another type of list, the parameterless constructor initialises the Collection with a List.

    An ArrayList is essentially the same as a List, so you would have to cast the items to String when reading from it.

    A StringCollection is just a type safe wrapper for an ArrayList.

    提交回复
    热议问题