CSC Interview Question: how to find common elements between two collections
Solution: retainAll method do this. public boolean retainAll (Collection<?> c) Example: public class Test { public static void main(String [] args){ LinkedHashSet hs = new LinkedHashSet(); // add elements to the hash set hs.add("B"); hs.add("A"); hs.add("D"); hs.add("E"); hs.add("C"); hs.add("F"); System.out.println(hs); LinkedHashSet hs2 = new LinkedHashSet(); ...