Skip to content

Instantly share code, notes, and snippets.

@ruimo
Created February 27, 2015 04:01
Show Gist options
  • Save ruimo/feff4f42fcea0c616a99 to your computer and use it in GitHub Desktop.
Save ruimo/feff4f42fcea0c616a99 to your computer and use it in GitHub Desktop.
import java.util.List;
import java.util.ArrayList;
import java.util.Arrays;
import static java.util.Objects.requireNonNull;
class Foo<T> {
final List<T> members;
@SafeVarargs
Foo(T... a) {
members = new ArrayList<>(Arrays.asList(requireNonNull(a)));
}
}
public class Test {
public static void main(String... args) {
Foo<String> foo = new Foo<>("Hello", "World");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment