question: public static String sortAndGetState ( ) { if ( _state . length ( ) == 0 ) { return _state ; } String [ ] states = _state . split ( "\\n" ) ; List < String > list = new ArrayList ( ) ; for ( int counter = 0 ; counter < states . length ; ++ counter ) { list . add ( states [ counter ] ) ; } Collections . sort ( list ) ; Iterator < String > iterator = list . iterator ( ) ; String value = "" ; while ( iterator . hasNext ( ) ) { value += iterator . next ( ) + "\n" ; } _state = "" ; return value ; }
target:  Splits state at new line character ('\n'), sorts the resulting array and returns joined array. Array is joined using '\n' as a delimiter between its members.