Array or List in Java. Which is faster?

后端 未结 30 1684
滥情空心
滥情空心 2020-11-22 04:30

I have to keep thousands of strings in memory to be accessed serially in Java. Should I store them in an array or should I use some kind of List ?

Since arrays keep

30条回答
  •  悲&欢浪女
    2020-11-22 04:48

    If you know in advance how large the data is then an array will be faster.

    A List is more flexible. You can use an ArrayList which is backed by an array.

提交回复
热议问题