Reputation: 1610
I just looked up array and arrayList
and found out that an array is fixed length and can't be changed while an arraylist can be changed and is variable in length
my question is:
is array == tuple in python?
and is arraylist == list in python?
and if they aren't what are array and arraylist's python equivalent?
Upvotes: 11
Views: 44319
Reputation: 86266
ArrayList
in java and list
in python are both dynamic arrays. They both have O(1) average indexing time and O(1) average adding an element to the end time.
Array
in java is not tuple
in python. While it is true that you cannot add elements to both data structures. Python tuple
does not support assignment, that is you cannot reassign individual elements in a tuple
, while you can in java Array
.
Upvotes: 20
Reputation: 69
Upvotes: 0