public String [ ] addToStringArray ( String [ ] strArray , String str ) { String [ ] result = null ; if ( strArray != null ) { result = new String [ strArray . length + 1 ] ; System . arraycopy ( strArray , 0 , result , 0 , strArray . length ) ; result [ strArray . length ] = str ; } return result ; }
Add the given string to the string array . This will create a new array expanded by one element copy the existing array add the given value and return the resulting array .