Return ArrayList or List?

Viewed 8005

I'm creating a library to be used by people but why should my method return a List instead of an ArrayList?

Because if the user knows the real type is an ArrayList he will use the accessor [] in a loop instead of iterator but if he doesn't know he will use an iterator.

Same question for LinkedList, if the return type is a List he won't be able to use the correct accessor.

Am I right?

8 Answers
Related