You need to have thousands of strings in memory that are accessible sequentially. Should I save the string to Array? Should I save it to the list? Unlike List, Array stores all data continuously in a lump of memory. If there are thousands of strings in an array, isn't that a problem?
Ask yourself: The difference in performance between the two is small, and the List interface is more flexible.
performance list java array container
I recommend you to test which one is faster using a profiler. And I personally recommend using List. When I was working in a place with a huge code base, previous developers used arrays everywhere, which made code very inflexible. And when we switched it to List, we barely felt the difference in speed.
© 2024 OneMinuteCode. All rights reserved.