if you want my opinion (<- see now you can’t tell me i’m wrong, it’s an opinion) then the difference is that an array is by definition a memory address that’s designated as the beginning of an array, and it’s got an offset because the first element is at that specific address and further items are offset from that address. so you add the offset to the address to get the nth item. a list, meanwhile, can be basically any implementation under the hood, but it’s commonly a linked list. the way you get the nth index there is you count up from the first position. since the implementation is opaque and may be spread out in memory you can’t arithmetic your way to an index, you need to follow the pointers.
java’s arraylist is a list backed by an array. java’s vector is a list backed by a linked list.
That doesn’t really address what you call it. Names only really just exist to get your point across. Inexperienced devs may not know what an offset means (or why we use that), so index does the job. An experience dev knows how it works anyway, so whether you say index or offset won’t matter. By virtue of the common denominator, I simply use index everywhere.
if you want my opinion (<- see now you can’t tell me i’m wrong, it’s an opinion) then the difference is that an array is by definition a memory address that’s designated as the beginning of an array, and it’s got an offset because the first element is at that specific address and further items are offset from that address. so you add the offset to the address to get the nth item. a list, meanwhile, can be basically any implementation under the hood, but it’s commonly a linked list. the way you get the nth index there is you count up from the first position. since the implementation is opaque and may be spread out in memory you can’t arithmetic your way to an index, you need to follow the pointers.
java’s arraylist is a list backed by an array. java’s vector is a list backed by a linked list.
That doesn’t really address what you call it. Names only really just exist to get your point across. Inexperienced devs may not know what an offset means (or why we use that), so index does the job. An experience dev knows how it works anyway, so whether you say index or offset won’t matter. By virtue of the common denominator, I simply use index everywhere.