I write the below code
package com.scjp.ch7;
import java.util.ArrayList;
import java.util.List;
public class GenericTest {
/**
* @param args
*/
public static <E extends Number> List <? super E> process (List<E> nums) {
return null;
}
public static void main(
String[] args) {
// TODO Auto-generated method stub
List<Integer> input = new ArrayList<Integer>();
List<Integer> output = new ArrayList<Integer>();
output = process(input);
}
}
It gives me this error.
[root@localhost ~]# javac GenericTest.java
GenericTest.java:22: incompatible types
found : java.util.List<capture of ? super java.lang.Integer>
required: java.util.List<java.lang.Integer>
output = process(input);
^
1 error
According to my study book it should work and when i eyeball it looks correct too. Is my book wrong? (for those interested pg. 634 qu.16 of Sun Certified Programmer for
Java 5.
regards
Harry