posted 13 years ago
Hi everybody,
I have this code:
Which of the following can be inserted at // to comile the code without error?
A. public static<T> List<T>backwards(List<T> input)
B. public static<T> List<T>backwards(List<? extends T> input)
C. public static<T> List<T>backwards(List<? super T> input)
D. public static<T> List<? extends T>backwards(List<T> input)
E. public static<T> List<? super T>backwards(List<T> input)
F. public static<? extends T> List<T>backwards(List<T> input)
The output is A,B,D,E.
I would like to know why letter B is correct instead of letter C ? Because in the code above there is a add method. I think that only List<? super T> could have a add method and not List<? extends T>.
Can anybody help me?