public static int Hamming ( String first , String second ) { if ( first . length ( ) != second . length ( ) ) throw new IllegalArgumentException ( "The size of string must be the same." ) ; int diff = 0 ; for ( int i = 0 ; i < first . length ( ) ; i ++ ) if ( first . charAt ( i ) != second . charAt ( i ) ) diff ++ ; return diff ; }
Gets the Hamming distance between two strings .