Type mismatch: cannot convert from List<capture-of ? super Integer> to List<Integer>
Type mismatch: cannot convert from List<capture-of ? super Integer> to List<Number>
Type mismatch: cannot convert from List<capture-of ? super Number> to List<Number>
SCJP 5.0, SCWCD 1.4, SCBCD 1.3, MySQL 5 Developer, ZCE, EUCIP Core<br /> <br />OCA 9i (in progress..)<br />SCJD UrlyBird (in progress..)
"I'm not back." - Bill Harding, Twister
Originally posted by Andrew Shumway:
Then, what version of List should be given to make it work. I tried, but I could not get anything to work.
[ January 30, 2006: Message edited by: Hamid Virani ]<hr></blockquote>
Using the Generics class above the following declarations work
Because Number both extends Number and is super of Number
Like the above I can see that the input list will work because Number extends Number. However I can't see List<? super Integer> qualifies when the process method will return List<? super Number> However, I don't get a compile error. I'm guessng that since all super classes of Number are also super classes of Integer it's ok.
This also works for the same reason as the first.
--andrew
[ February 02, 2006: Message edited by: Andrew Shumway ][/QB]
by Jim Yingst
...correct version of this question used the following declaration for process():
public static <E extends Number> List<E> process(List<E> nums) {
Consider Paul's rocket mass heater. |