To store the modified string
String res = " " ; for ( int i = 0 ; i < len ; i ++ ) { if ( str . charAt ( i ) != ' ) ' && str . charAt ( i ) != ' ( ' ) { res += ( str . charAt ( i ) ) ; } } return res ; }