Jack Snipes wrote:So, my question is, is it a better practice to use a List as an argument, or an array when the method itself doesn't care about which to use?
My opinion: A
List - or possibly even a
Collection (the general rule being: "the vaguer the better"
).
Arrays are a very specific animal: For one thing they have a
fixed size; Lists don't. They can also be a PITA when they involve types.
For example, you can't
create an array of
Comparators, eg:
Comparator<String>[] comparators;
without an explicit cast, viz:
Comparator<String>[] comparators = (Comparator<String>[]) new Comparator[10];
and even then I think you get a compiler warning.
You can certainly create a
List of them though:
List<Comparator<String>> comparators = new ArrayList<>();
HIH
Winston