Check for the condition of anagram
String copy_S1 = S1 , copy_S2 = S2 ; char [ ] t1 = copy_S1 . toCharArray ( ) ; char [ ] t2 = copy_S2 . toCharArray ( ) ; Arrays . sort ( t1 ) ; Arrays . sort ( t2 ) ; copy_S1 = new String ( t1 ) ; copy_S2 = new String ( t2 ) ; if ( ! copy_S1 . equals ( copy_S2 ) ) { return false ; }