Compare two ArrayList and remove duplicates in Java
Given two ArrayLists, the task is to print all common elements in both the ArrayLists in Java . Examples: Input: List1 = ["Hii", "Geeks", "for", "Geeks"], List2 = ["Hii", "Geeks", "Gaurav"] Output: [Hii, Geeks, Geeks] Input: List1 = ["a", "b", "c", "d", "e", "f"], List2 = ["b", "d", "e", "h", "g", "c"] Output:[b, c, d, e]
Practice Tags : |