-
-
Save ryanirilli/ca2ae301df0a1679716f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Set; | |
import java.util.HashSet; | |
class Test{ | |
public static void main(String[] args){ | |
Set<String> a = new HashSet<String>(); | |
Set<String> b = new HashSet<String>(); | |
a.add("a"); | |
b.add("b"); | |
Set<String> c = union(a, b); | |
System.out.println(c.size()); | |
} | |
public static <E> Set<E> union(Set<E> s1, Set<E> s2) { | |
Set<E> result = new HashSet<E>(s1); | |
result.addAll(s2); | |
return result; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment