Java Generic Method with both return type and generic type
import java.util.HashSet; import java.util.Set; public class Main { public static <T> boolean isSubset(Set<T> s1, Set<T> s2) { return s1.containsAll(s2); }/*from ww w .j a v a 2 s . com*/ public static void main(String[] args) { Set<String> s1 = new HashSet<>(); s1.add("HTML"); s1.add("CSS"); s1.add("XML"); Set<String> s2 = new HashSet<>(); s2.add("XML"); s2.add("CSS"); System.out.println(s1); System.out.println(s2); boolean s3 = isSubset(s1, s2); System.out.println(s3); s3 = isSubset(s2, s1); System.out.println(s3); } }