Now if there are adjacent similar character remove that character from s1
for ( int i = 1 ; i < s1 . length ( ) ; i ++ ) if ( s1 . charAt ( i ) != s1 . charAt ( i - 1 ) ) { a += getString ( s1 . charAt ( i ) ) ; }