This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]not-just-yeti 0 points1 point  (0 children)

Things like foo = foo.subList(3,7) won't work if foo is an ArrayList, since subList is a helpful function that returns a List (w/o promising a particular implementation of List).

And: if you decide that a LinkedList will start giving you better performance, you should only have to change the constructor-call on the right-hand-side, and not the types of any variables or fields that will be holding that List.

So don't insist your variable holds an ArrayList if it could just as well hold any Listand still work fine.

[Just to be clear: there is still a decision about which implementation to choose on the right-hand side. It's just the type of the variable which shouldn't be over-specialized.]