I have an Arraylist
ArrayList<WorkPosition> info = new ArrayList<>();
where in some point, I add some objects. At the end this arrayList has the same object multiple times.. The object has some int values and 2 arraylists
97 [9, 10, 15] [1202, 1204, 2082]
97 [9, 10, 15] [1202, 1204, 2082]
97 [9, 10, 15] [1202, 1204, 2082]
42 [14, 16, 29] [404, 1081, 1201D]
42 [14, 16, 29] [404, 1081, 1201D]
42 [14, 16, 29] [404, 1081, 1201D]
57 [18, 30, 32] [2081, 435, 1032]
57 [18, 30, 32] [2081, 435, 1032]
57 [18, 30, 32] [2081, 435, 1032]
34 [19, 27, 28] [4501, 831, 201]
34 [19, 27, 28] [4501, 831, 201]
34 [19, 27, 28] [4501, 831, 201]
Is there any way to delete the extra appearances?
I read this How do I remove repeated elements from ArrayList? but in my case I don't have Strings
but objects type of WorkPosition
..
public class WorkPosition {
private int id;
ArrayList<Integer> machines = new ArrayList<>();
ArrayList<String> bottles= new ArrayList<>();
public WorkPosition(int id, ArrayList<Integer> machines, ArrayList<String> bottles) {
this.id = id;
this.machines = machines;
this.kaloupia = kaloupia;
}
//getters and setters...
}