I was wondering how I can do the following: I have 2 arraylists with the values in them associated with each other. i.e. The elements of the arraylists on the same index are related to each other. For example: ArrayList 1 (String arraylist) = [id1, id2, id3, id2, id2, id1]. ArrayList 2 (integer arraylist) = [2, 3, 2, 5, 6, 3].
I want to create 2 new arraylists with the duplicate values not existing anymore. In the above case, the new arraylists should be arraylist1 = [id1, id2, id3]. arraylist2 = [5, 14, 2]. i.e., the values in the second arraylist get added accordingly (since they are associated with the values in the first arraylist on the same index).
I don't understand how to get started with this.
new ArrayList<>(new LinkedHashSet<>(listWithDuplicates)).class? That way merging would be way easier