It is pretty obvious that array[10] is faster than array.get(10), as the later internally does the same call, but adds the overhead for the function call plus additional checks.

Modern JITs however will optimize this to a degree, that you rarely have to worry about this, unless you have a very performance critical application and this has been measured to be your bottleneck.

Answer from TwoThe on Stack Overflow
🌐
Baeldung
baeldung.com › home › java › java array › array vs. list performance in java
Array vs. List Performance in Java | Baeldung
March 7, 2025 - The array has a quicker item retrieval time of (163.559 ns/op). In comparison, the ArrayList‘s item retrieval time is longer at (261.106 ns/op) due to additional checks performed on the backing array.
Discussions

Java: Is Arraylist better than Arrays?
The biggest difference is that you can add to and remove from a list, whereas arrays have a fixed size. More on reddit.com
🌐 r/learnprogramming
28
19
June 23, 2024
Array or List in Java. Which is faster? - Stack Overflow
But with the JVM we have, arrays are a foundational type in Java. 2019-08-08T13:43:26.317Z+00:00 ... Save this answer. ... Show activity on this post. Although the answers proposing to use ArrayList do make sense in most scenario, the actual question of relative performance has not really been ... More on stackoverflow.com
🌐 stackoverflow.com
java - are arrays faster than arraylist? - Stack Overflow
Array or List in Java. Which is faster? (32 answers) Closed 8 years ago. My intuition says arrays are faster than arraylist because arraylists are implemented using arrays that resize as it fills up/loses elements. I just wanted to confirm if this is true or not, implying there's never a reason to use an arraylist if you know the number of elements you want to hold. ... If you can guarantee that, you could go ahead with an array for performance ... More on stackoverflow.com
🌐 stackoverflow.com
July 26, 2016
List vs Array vs ArrayList
These are three different things: Array - a very basic data structure. It has a fixed, predetermined size that must be known at the time of creating (instantiating) the array. Think of it as a sorting box with several slots. Here, you have .length - without parentheses as it is a property, not a method List - an interface (not a class) that defines certain behavior. It cannot be instantiated on its own. ArrayList - a concrete class that implements the List interface. When you see a declaration like List data = new ArrayList<>(); there are several things going on: Listprogramming against the interface - here, the interface List is used as data type - this is good practice as it allows you to at any time change the internal representation of the List - e.g. from ArrayList to LinkedList if you figure out that the other better suits your needs. this is a data type identifier. It limits the type of elements that can be stored in the list. Here, only String objects are allowed. If you were to omit this, the list would store Object (the ancestor of all Java classes) and descendant instances (i.e. Object and any subclass of it). data - just the variable name new - the keyword to create a new Object Instance ArrayList<>() - the constructor call. Here, the constructor without parameters of the ArrayList class is called. The diamond operator <> is used to infer (take) the data type for the ArrayList from the variable type (here String). So, the whole is: we create a new variable of type List that can only accept String elements and ist internally represented as ArrayList. More on reddit.com
🌐 r/javahelp
15
7
September 12, 2023
🌐
Medium
medium.com › @AlexanderObregon › java-arrays-and-arraylists-a-comparative-look-bcbc97b32a1e
Java Arrays vs ArrayLists Guide | Medium
November 18, 2023 - Arrays: More memory efficient for storing large numbers of elements, as they have a lower memory overhead. ArrayLists: Have additional memory overhead due to the dynamic resizing capability and storage of object references.
🌐
Reddit
reddit.com › r/learnprogramming › java: is arraylist better than arrays?
r/learnprogramming on Reddit: Java: Is Arraylist better than Arrays?
June 23, 2024 -

I've been programming in Java for 10 months now (as a subject in school) and i was always curious whats the biggest difference between Areays and Arraylist. I know that if i had an Arraylist named 'list' and i wrote System.out.print(list) it will print all the things that the list contains. Something that Arrays can't do that easily. But whats the actually biggest difference?

🌐
Coderanch
coderanch.com › t › 690574 › java › Array-Arraylist-Performance
Array vs Arraylist Performance (Performance forum at Coderanch)
February 11, 2018 - ArrayList is internally backed by Array in Java, any resize operation in ArrayList will slow down performance as it involves creating new Array and copying content from old array to new array.
Top answer
1 of 16
410

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.

2 of 16
181

The Java way is that you should consider what data abstraction most suits your needs. Remember that in Java a List is an abstract, not a concrete data type. You should declare the strings as a List, and then initialize it using the ArrayList implementation.

List<String> strings = new ArrayList<String>();

This separation of Abstract Data Type and specific implementation is one the key aspects of object oriented programming.

An ArrayList implements the List Abstract Data Type using an array as its underlying implementation. Access speed is virtually identical to an array, with the additional advantages of being able to add and subtract elements to a List (although this is an O(n) operation with an ArrayList) and that if you decide to change the underlying implementation later on you can. For example, if you realize you need synchronized access, you can change the implementation to a Vector without rewriting all your code.

In fact, the ArrayList was specifically designed to replace the low-level array construct in most contexts. If Java was being designed today, it's entirely possible that arrays would have been left out altogether in favor of the ArrayList construct.

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 ?

In Java, all collections store only references to objects, not the objects themselves. Both arrays and ArrayList will store a few thousand references in a contiguous array, so they are essentially identical. You can consider that a contiguous block of a few thousand 32-bit references will always be readily available on modern hardware. This does not guarantee that you will not run out of memory altogether, of course, just that the contiguous block of memory requirement is not difficult to fufil.

🌐
Medium
medium.com › lets-do-it-pl › arrays-vs-arraylist-99b3d845e404
Arrays vs ArrayList. With explanation and comparison in Java | by M. Hamdi Ozdil | Let’s Do It PL | Medium
April 12, 2021 - Furthermore, ArrayLists can hold only Objects, and they usually store more place than Arrays. Even though Arrays are faster than ArrayLists, fast execution consumes more memory than ArrayList.
Find elsewhere
🌐
Blogger
javarevisited.blogspot.com › 2016 › 01 › 9-difference-between-array-vs-arraylist-in-java.html
Difference between a List and Array in Java? ArrayList vs Array Example
Since ArrayList internally uses an array, it's bound to have a lot of similarities as seen below: Both allow you to store objects in Java and both are an index-based data structure that provides O(1) performance to retrieve an element, but search ...
🌐
Coderanch
coderanch.com › t › 568811 › java › Array-ArrayList
Array vs ArrayList (Performance forum at Coderanch)
If you do not exceed the capacity it is going to be as fast as an array. Better handling and much easier way of doing things. Something like : Convert to an array · Victor M. Pereira ... Array is faster and that is because ArrayList uses a fixed amount of array.
🌐
Codemia
codemia.io › home › knowledge hub › array or list in java. which is faster?
Array or List in Java. Which is faster? | Codemia
January 26, 2025 - Both arrays and lists have their uses, and choosing between them depends squarely on the requirements of your application. Arrays are generally faster and simpler, suitable for static data sets. Lists offer more flexibility and are appropriate when dealing with dynamically changing data.
🌐
How to do in Java
howtodoinjava.com › home › java array › java array vs. arraylist: comparison and conversion
Java Array vs. ArrayList: Comparison and Conversion
July 3, 2024 - ArrayLists take away the complexity and make the code more readable and provide almost similar performance for small collections. The best way to gauge the performance gains is to measure it using any tool such as JMH.
🌐
JA-VA Code
java-performance.info › home › arraylist in java: unleashing the power of dynamic arrays
ArrayList in Java: Unlocking the Potential - School
October 9, 2023 - Let’s pit ArrayLists against regular arrays to understand their performance differences.
🌐
LinkedIn
linkedin.com › pulse › array-vs-arraylist-java-omar-ismail
Array vs ArrayList in Java
September 5, 2021 - To use ArrayList we need to ... it comes with many inbuilt functionalities but at the same time, it has poor performance efficiency than arrays....
🌐
javathinking
javathinking.com › blog › array-or-list-in-java-which-is-faster
Java Array vs List: Which is Faster for Storing Thousands of Strings? Serial Access & Memory Considerations — javathinking.com
This is due to the lack of method call overhead and minimal bounds-checking in arrays. However, with JIT optimizations, the gap narrows—ArrayList.get() is frequently inlined, making performance nearly identical in practice for most applications.
🌐
Jenkov
jenkov.com › tutorials › java-performance › java-arraylist-vs-openarraylist-performance.html
Java ArrayList vs. OpenArrayList Performance
As you can see, iterating an ArrayList using the for-each loop and Iterator yields pretty much the same performance. This was expected, as the for-each loop is probably compiled into an iteration using an Iterator by the Java compiler.
🌐
sqlpey
sqlpey.com › java › java-array-vs-arraylist-performance
Java Array vs ArrayList Performance When Storing Thousands of Strings
July 29, 2025 - Prioritize Flexibility and Cleanliness: In most scenarios involving strings, the flexibility, generics support, and dynamic sizing offered by ArrayList are preferred over the marginal speed gains of a raw array. If the codebase is large, refactoring toward the List interface improves code maintainability significantly. Profile First: Do not prematurely optimize. Measure performance using profiling tools or dedicated benchmarking libraries (like JMH) before concluding that the array is necessary.
🌐
TechVidvan
techvidvan.com › tutorials › java-array-vs-arraylist
Difference Between Array and ArrayList in Java - TechVidvan
June 17, 2020 - To use ArrayList we need to ... it comes with many inbuilt functionalities but at the same time, it has poor performance efficiency than arrays....
🌐
Java67
java67.com › 2012 › 12 › difference-between-array-vs-arraylist-java.html
Difference between Array vs ArrayList in Java | Java67
That's all on the difference between Array and ArrayList in Java. In terms of performance Array and ArrayList provides similar performance in terms of constant time for adding or getting element if you know index.
🌐
Arnaudroger
arnaudroger.github.io › blog › 2018 › 06 › 01 › arraylist-vs-arrays.html
ArrayList.get(i) vs array[i]
June 1, 2018 - With 10 and 1000 elements the number of cache misses is pretty low, the number of instruction and the CPI are lower for Array - no wonder it’s faster less to do, and less cycle to do it -. But on the 1000000 size array there are loads of cache misses. They end-up dominating the performance, increasing the CPI to 1.6 for the Array. The only reason the ArrayList does not score as bad is because it has a lot more instructions.
Top answer
1 of 8
29

Any performance difference will be negligible, especially if you initialize your arraylist with an initialCapacity. Write your code in whatever way makes it the most readable and maintainable, and try not to optimize stuff like this unless you've determined through testing that you are getting a significant performance hit from it.

Potential reasons to use ArrayList:

  • useful methods (contains, etc.)
  • implements Iterable, Collection, and List, and can therefore be used in a lot of API calls that are interface-based.
  • even though you currently "know" that your collection's size can never change, life throws unexpected requirements at us. Why lock yourself into a pattern when there's no discernible advantage to be gained?
2 of 8
7

ArrayList gives you many features a raw array does not have. If you know the number of elements you can create an ArrayList of that size.

new ArrayList<String>(100);

If you are worrying about the difference in speed between an ArrayList and an array, you are worrying about the wrong thing. It is highly unlikely to be the bottleneck in your code. If it is, there is almost certainly a better answer than changing to an array.

Don't succumb to premature optimization. It'll wreak havoc on your code. Most things don't matter, only a few things do. You can only find those few things by profiling your code. Trying to make every part fast is a very ineffective way of making the whole fast. Keeping a clean, simple design is much more effective. That will give you the necessary seams for introducing optimizations in the one or two places they're actually needed.