Array or List in Java. Which is faster?

后端 未结 30 2124
滥情空心
滥情空心 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 05:14

    I suggest that you use a profiler to test which is faster.

    My personal opinion is that you should use Lists.

    I work on a large codebase and a previous group of developers used arrays everywhere. It made the code very inflexible. After changing large chunks of it to Lists we noticed no difference in speed.

提交回复
热议问题