I’m trying to think of the best way to return an empty array, rather than null.
Is there any difference between foo() and bar()?
private static File[] foo() {
return Collections.emptyList().toArray(new File[0]);
}
private static File[] bar() {
return new File[0];
}
A different way to return an empty array is to use a constant as all empty arrays of a given type are the same.