| Author |
Problem with Generics
|
Arsineh Keshishian
Greenhorn
Joined: Apr 21, 2008
Posts: 19
|
|
Hi guys, I'm having problem with question 16 in chapter 7(Generics). Given a method declared as: public static <E extends Number> List<? super E> process(List<E> nums) And // INSERT DECLARATIONS HERE output = process(input); Why is the following declaratin wrong? ArrayList<Integer> input = null; List<Number> output = null; Assumed <E> resolves to <Integer>. Then the return type List<? super E> could be resovled to List<Number> since Number is the ancestor of Integer. So what is wrong about this? Please, I'm not getting this Thank you very much! Arsineh
|
 |
Frank Hinkel
Greenhorn
Joined: Mar 28, 2008
Posts: 24
|
|
Howdy, its just a DrunkenKathyAndBertWhileWritingBooksError. Correct line looks like: public static <E extends Number> List<E> process(List<E> nums)
|
 |
Tarun Kumar
Greenhorn
Joined: Apr 30, 2008
Posts: 26
|
|
this problem come earlier also on the forum. actually it simisprinting. public static <E extends Number> List<? super E> process(List<E> nums) it is correctly as public static <E extends Number> List<E> process(List<E> nums)
|
Tarun Kumar
|
 |
Arsineh Keshishian
Greenhorn
Joined: Apr 21, 2008
Posts: 19
|
|
Thank you very much
|
 |
 |
|
|
subject: Problem with Generics
|
|
|