Edit Distance code in Java