Results 1 to 4 of 4
Thread: Couple of Generics questions
- 03-30-2011, 03:28 PM #1
Member
- Join Date
- Mar 2011
- Posts
- 2
- Rep Power
- 0
Couple of Generics questions
Java Code:public class Try { public static void main(String[] prms) { ArrayList<ArrayList<A>> lla = new ArrayList<ArrayList<A>>(); ArrayList<ArrayList<B>> llb = new ArrayList<ArrayList<B>>(); ArrayList<A> la = new ArrayList<A>(); ArrayList<B> lb = new ArrayList<B>(); stam(lla); //compiler error stam(llb); //compiler error stam2(lla); stam2(llb); stam3(lla); stam3(llb); stam4(la); stam4(lb); stam5(la); stam5(lb); } static void stam(ArrayList<ArrayList<? extends A>> list){} static void stam2(ArrayList<? extends ArrayList<? extends A>> list){} static <T extends A> void stam3(ArrayList<ArrayList<T>> list){} static <T extends A> void stam4(ArrayList<T> list){} static void stam5(ArrayList<? extends A> list){} } class A { } class B extends A { }
=======================================
In the code above, the calls to stam() don't work.
My main question is why the calls to Stam() don't work, while the calls to stam2() just below it do work.
Also, if someone could clarify the difference between using wildcards and using T I'll be greatful.
- 03-31-2011, 05:51 AM #2
Senior Member
- Join Date
- Jan 2009
- Posts
- 671
- Rep Power
- 5
This seems to me like a compiler bug to me.
- 03-31-2011, 06:15 AM #3
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
- 03-31-2011, 09:37 AM #4
Member
- Join Date
- Mar 2011
- Posts
- 2
- Rep Power
- 0
Similar Threads
-
Couple more questions on JAR Files :S
By Lil_Aziz1 in forum New To JavaReplies: 13Last Post: 06-05-2010, 08:44 AM -
Couple questions about Java
By theadolescent in forum New To JavaReplies: 3Last Post: 05-19-2010, 02:13 AM -
Couple Questions on Thread
By Lil_Aziz1 in forum Threads and SynchronizationReplies: 5Last Post: 01-06-2010, 02:02 PM -
Couple of questions regarding threading
By exernet in forum New To JavaReplies: 1Last Post: 12-15-2009, 12:23 PM -
Couple of newbie questions
By ananasman in forum New To JavaReplies: 11Last Post: 11-20-2008, 11:54 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks