| Author |
Question about generics
|
big van
Greenhorn
Joined: Jan 08, 2007
Posts: 3
|
|
Given a method declared as: public static <E extends Number> List<? super E> process(List<E> nums) A programmer wants to use this method like this: // INSERT DECLARATIONS HERE output = process(input); Which pairs of declarations could be placed at // INSERT DECLARATIONS HERE to allow the code to compile? (Choose all that apply.) A.ArrayList<Integer> input = null; ArrayList<Integer> output = null; B. ArrayList<Integer> input = null; List<Integer> output = null; C. ArrayList<Integer> input = null; List<Number> output = null; D. List<Number> input = null; ArrayList<Integer> output = null; E. List<Number> input = null; List<Number> output = null; F. List<Integer> input = null; List<Integer> output = null; G. None of the above. Why C is incorrect?
|
 |
big van
Greenhorn
Joined: Jan 08, 2007
Posts: 3
|
|
|
who can help me?
|
 |
Ilja Preuss
author
Sheriff
Joined: Jul 11, 2001
Posts: 14112
|
|
|
Please tell us first what *you* think about it.
|
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
|
 |
big van
Greenhorn
Joined: Jan 08, 2007
Posts: 3
|
|
I think, because "ArrayList<Integer> input = null" , E = Integer; So "List<? super E>" = List<? super Integer>. And Integer IS-A Number. ???
|
 |
 |
|
|
subject: Question about generics
|
|
|