Possible Duplicate:
Array or List in Java. Which is faster?
I started a project where I will be constantly accessing an Arraylist that will never be changed. Would it be faster to access an ArrayList or an Array and by how much?
Possible Duplicate:
Array or List in Java. Which is faster?
I started a project where I will be constantly accessing an Arraylist that will never be changed. Would it be faster to access an ArrayList or an Array and by how much?
The difference will probably not be noticeable as the JVM will most likely optimise the call if you use it very often. And using List
will give you a more robust and flexible code, so I would personally use List
s.
There is only one way to know: test it (after having read this post about how to test the performance of a Java application).
if its constant, how about an Enum, you can add logic directly to the enum instances.