Why do we need generic methods in Java?

1. A Method without Generic Type Assuming you want to write a method that takes two sets and get their intersection. Here is one way to write such a method: public static Set getIntersection(Set set1, Set set2){ Set result = new HashSet();   for(Object o: set1){ if(set2.contains(o)) result.add(o); }   return result; }public static Set … Read more