public String getDisplay ( HashSet < String > s , String a , String b ) { if ( s . contains ( a ) ) { s . add ( b ) ; } else { s . add ( a + b ) ; } StringBuilder sb = new StringBuilder ( ) ; Iterator < String > it = s . iterator ( ) ; while ( it . hasNext ( ) ) { sb . append ( it . next ( ) ) ; } return sb . toString ( ) ; }
tag OCP hashset could be Set instead