public static List < String > trimIt ( String [ ] strings ) { if ( strings == null || strings . length == 0 ) { return null ; } List < String > results = new ArrayList < String > ( ) ; for ( int i = 0 ; i < strings . length ; i ++ ) { String result = trimIt ( strings [ i ] ) ; if ( result != null ) { results . add ( result ) ; } } if ( results . size ( ) > 0 ) { return results ; } else { return null ; } }
Trims each of the strings in the array provided and returns a new list with each string added to it . If the trimmed string is empty that string will not be added to the final array . If no entries are present in the final array null is returned .