posted 18 years ago
The following is part of a question from the K&B study guide.
Given a method declared as:
public static <E extends Number> List<? super E> process(List<E> nums)
A programmer wants to use this method like this:
// INSERT DECLARATIONS HERE
output = process(input);
Which pairs of declarations could be placed at // INSERT DECLARATIONS HERE to allow the code to compile? (Choose all that apply.)
A)
ArrayList<Integer> input = null;
ArrayList<Integer> output = null;
Answer A shown above was stated as being incorrect as 'The return type of process is definitely declared as a List, not an ArrayList'. The above confused me so I tried out the following code which seemed to compile fine. So is the answer above correct or (more likely) am I confused.
Thanks
Tom