java - Returning an empty array -


question

this may silly question, there difference between foo() , bar()?


code

private static file[] foo() {     return collections.emptylist().toarray(new file[0]); } 

private static file[] bar() {     return new file[0]; } 

i'm trying think of best way return empty array, rather null.

a different way return empty array use constant empty arrays of given type same.

private static final file[] no_files = {}; private static file[] bar(){     return no_files; } 

Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -