I’m having trouble with a generics. I have defined the following static method:
public static <E extends Number> List<E> group(E ... numbers) {
return Arrays.asList(numbers);
}
I understand why this works:
List<Integer> ints = group(1, 2, 3);
But what do I have to change in my method signature to make this work:
List<Number> ints = group(1, 2, 3);
Or should I just call the group method specifying the Number type as:
List<Number> ints = MyClass.<Number>group(1, 2, 3);
Thanks in advance.
You need to explicitly specify
Numberas the type argument, as you suggested.