Android Question Array vs List which is faster

Robert Valentino

Well-Known Member
Licensed User
I am trying to understand which is quicker.

When I use an array or types I can index directly into the array and change a field on a type
Array(x).TypeName = xxx

In a List I have to Get the type into a Type variable, change the value and then Set the Type back into the List.

When expanding a Array I have to make a new array on size bigger and copy over the whole array
When expanding a List I can just Add an entry

Do these trade offs mean anything?

Is there ANY savings using one over the other? If so when?

Thanks

BobVal
 

AllyAndroid

Member
Licensed User
As far as speed goes, I don't think you will notice a difference if you use one or the other.

An ArrayList is a list that is backed by an array, so even though it is easier to add an entry, it is still creating a new array each time. At least, that is the way I understand it to work.
 
Top