Example

public NullEmptyArray_Exemplo() {
super();
}

public void addValue( Integer value ) {
if ( values == null ) {
values = new ArrayList(10);
}
values.add( value );
}

public Integer[] getValues() {
if ( values == null ) {
return null;
}
return (Integer[])values.toArray( new Integer[ 0 ] );
}

private List values;

public static void main( String[] args ) {
NullEmptyArray_Exemplo example = new NullEmptyArray_Exemplo();
Integer[] values = example.getValues();
for ( int i = 0; i < values.length; i++ ) {
System.out.println( values[ i ] );
}
}

Solução
Retorne uma matriz de comprimento zero em vez de nula.

public NullEmptyArray_Solution() {
super();
}

public void addValue( Integer value ) {
if ( values == null ) {
values = new ArrayList(10);
}
values.add( value );
}

public Integer[] getValues() {
return ( values == null ) ? new Integer[ 0 ] :
(Integer[])values.toArray( new Integer[ 0 ] );
}

private List values;

public static void main( String[] args ) {
NullEmptyArray_Solution example = new NullEmptyArray_Solution();
Integer[] values = example.getValues();
for ( int i = 0; i < values.length; i++ ) {
System.out.println( values[ i ] );
}
}