0 votes
1 view
in Java by (5.8k points)
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 all the data in a contiguous chunk of memory (unlike Lists), would the use of an array to store thousands of strings cause problems?

1 Answer

0 votes
by (34.9k points)
I recommend that you use a profiler to examine which is faster.

My own belief is that you should apply Lists.

I operate on a large codebase and a preceding group of developers used arrays throughout. It made the code very firm. After replacing large chunks of it to Lists we discerned no variation in speed.
...