Skip to main content
18 events
when toggle format what by license comment
Feb 9, 2015 at 18:10 history tweeted twitter.com/#!/StackProgrammer/status/564848942316539904
Feb 8, 2015 at 6:14 history edited InformedA CC BY-SA 3.0
add an answer in the foot note
Feb 8, 2015 at 6:04 history edited InformedA CC BY-SA 3.0
added 108 characters in body
Feb 8, 2015 at 5:57 vote accept InformedA
Feb 6, 2015 at 14:23 answer added Doval timeline score: 7
Feb 6, 2015 at 4:32 comment added InformedA @Doval Just check with JDK, T super E does not even compile.
Feb 6, 2015 at 4:19 comment added InformedA @Doval please elaborate with an example in a proper answer. I can use T extends E for T super E, and if needed simply E for T super E .
Feb 5, 2015 at 15:39 comment added Doval Yes, and you can change ? super E for T super E, but not for T extends E. super != extends. That is my point.
Feb 5, 2015 at 15:36 comment added InformedA There is a duality between type parameters and wildcards
Feb 5, 2015 at 15:34 comment added Doval I don't see anything in ggovan's answer that's relevant. ? super E stands for any type that's a superclass of E while T extends E stands for a type that's a subclass of E. Let's say E is Number. popAll(List<? super E>) makes sense because it makes sense to put Numbers into a list of Objects. If you change that to <T extends E> ... List<T>, it doesn't make sense to put Numbers into a List<Integer> because the Number you add may not be an Integer at all.
Feb 5, 2015 at 15:10 comment added InformedA @Doval Or you can read the second quoted block in the answer from ggovan
Feb 5, 2015 at 15:07 comment added InformedA @Doval Try it yourself and see where the idea is from.
Feb 5, 2015 at 14:14 comment added Doval "But List<List<?>> is not flexible" you've got it the wrong way around. The more restrictions you put on the implementer, the more freedom you're giving the caller. The fact that the implementer can't make any assumptions about the contents of the inner Lists means the caller can give them any list-of-lists. That aside, I don't know where you're getting this idea that you can substitute ? super E with T extends E.
Feb 5, 2015 at 13:35 answer added ggovan timeline score: 3
Feb 5, 2015 at 6:01 comment added InformedA @Thomas Eding But List<List<?>> is not flexible (cannot insert other than null) as <E extends Object> List<List<E>>. The latter one is equally permissive.
Feb 5, 2015 at 5:37 comment added Thomas Eding They increase flexibility. They are useful to accept code you cannot accept with normal type parameters in java. Example would be List<List<T>> is not as permissive as List<List<?>>. en.wikipedia.org/wiki/…
Feb 5, 2015 at 3:48 history edited Stephen CC BY-SA 3.0
Changed it to a question.
Feb 5, 2015 at 3:38 history asked InformedA CC BY-SA 3.0