remove duplicates code in java