Revising some common algorithms in Java