Standard Place for an Empty String Array in the JDK
- by Simon B
Hi is there a standard place for accessing empty array constants in the JDK 1.5.
When I want to do a conversion from a String Collection (e.g. ArrayList)to a String Array I find myself using my own
which is defined in my own Constants class:
public static final String[] EMPTY_STRING_ARRAY = new String[0];
And then in my client code something like:
String[] retVal = myStringList.toArray(Constants.EMPTY_STRING_ARRAY);
return retVal;
I was wondering if this is the "idiomatic" of doing it or if I'm missing something
I get the impression from the brief search I did that this kind of thing is prevalent in many people's code.
Any ideas, answers, comment (aside from that I shouldn't really use String Arrays) greatly appreciated,
Cheers
Simon