Inversion_problem (Java )