3 ms·
> In Java it’s called Vector / list refers to linked list What?!! No! Vector is almost never used in Java code. When you need index-based access, ArrayList is
by brabel 8mo ago
> In Java it’s called Vector / list refers to linked list
What?!! No! Vector is almost never used in Java code. When you need index-based access, ArrayList is the much more common one, and it does implement List. So I would agree with parent commenter that List is the equivalent in Java.
A List in Java is a container that allows iterating over items efficiently, but does not necessarily provide efficient random access: https://docs.oracle.com/javase/8/docs/api/java/util/List.html https://docs.oracle.com/javase/8/docs/api/java/util/List.htm...
If you care about why Vector is nearly never used: it is synchronized by default, making it slower and more complex than ArrayList. Most Java programmers would prefer to implement synchronization themselves in case multi-threading is required since it nearly always involves having to synchronize multiple list operations at the same time, which cannot be done with Vector.
It's the same reason no one uses StringBuffer, but StringBuilder.
- vlovich123 8mo agoI’m aware. The preferred name is clearly Vector and ArrayList is the wordy alternative they had to use to not break back compat. List is the name to the interface which encompasses a lot of different data types. But ask a Java programmer of they prefer to use arrays or lists and I suspect they won’t even think twice about understand that the list you’re referring to is a linked list rather than asking what you mean because arraylist implements list. A fun Java weirdness is that of course arrays themselves do not implement list
- brabel 8mo agoYou are really out of touch, LinkedList is very widely regarded as bad for performance in nearly every scenario possible and thus hardly ever used. Array VS Arraylist is a valid question because they have very different properties.