About Question com.enthuware.ets.scjp.v6.2.100 :
Posted: Wed Oct 08, 2014 11:37 am
Hi. I'm being linked here from:
The signature of a method in a class is as follows:
public static <E extends CharSequence> List<? super E> doIt(List<E> nums)
This method is being called in the following code:
result = doIt(in);
Given that String implements CharSequence interface, what should be the reference type of 'in' and 'result' variables?
Answer:
ArrayList<String> in;
List result;
-------------------
I'm having trouble with this. If method returns <? super E> why does it not fit into Object type variable?
What's the difference between this and getting something out of Collection<? super E> and into Object variable?
The signature of a method in a class is as follows:
public static <E extends CharSequence> List<? super E> doIt(List<E> nums)
This method is being called in the following code:
result = doIt(in);
Given that String implements CharSequence interface, what should be the reference type of 'in' and 'result' variables?
Answer:
ArrayList<String> in;
List result;
-------------------
I'm having trouble with this. If method returns <? super E> why does it not fit into Object type variable?
What's the difference between this and getting something out of Collection<? super E> and into Object variable?