I am pretty new here, so excuse me if you do not understand my question.(Be nice :D) So basically I have to make a method which select positives "numbers" from a list using Generics.
The base of the method should look like this :
public static <T> List<T> selectPositives(List<? extends Number> list) {
T positiveNumber = null;
for (int i = 0; i < list.size(); i++) {
if (list.get(i) > 0) {
return (List<T>) positiveNumber;
}
}
return (List<T>) positiveNumber;
}
Well obviously this is not working, so I would greatly appreciate any help. Thanks, Alma