Let's say I have three Lists free, home and tableau, they all contains different objects. I also have a class called History and its constructor takes all these three lists and makes a new Object. Now, I am trying to make a List<History> that contains all the history objects. I am adding all the <History> objects as follows,
List<Hisotry> history = new ArrayList<>();
history.add(new History(free, home, tableau));
//make some changes in the lists (free, home, tableau),
//then add it again in the history list
history.add(new History(free, home, tableau));
//make some more changes again then add it
history.add(new History(free, home, tableau));
Although it's adding all the objects into the list, but they all referring to the same object. In other words, if I add 3 <History> objects, it prints the same <Hisotry> object 3 times, when they all should be different. I am not sure why it's adding or referring to the same object when each time I create a new object and add it to the list. What am I doing wrong while adding new objects?
**P.S. I hope I am making sense, if not, please feel free to let me know and I will upload my whole code.
