I have two lists containing the same objects. How do I change one list without changing the other? [duplicate]
问题 This question already has answers here : How do you make a deep copy of an object? (19 answers) Closed 4 years ago . I first noticed this problem when I only put the objects in listOfRates and then created inverseListOfRates by copying it. But even using this method, I can't alter one list without altering the other. How do I solve this issue? List<HistoricRate> listOfRates = new ArrayList<HistoricRate>(); List<HistoricRate> inverseListOfRates = new ArrayList<HistoricRate>(); for