What about this solution

public class Test {

abstract class A{

}

 class B extends A{

}

 ArrayList<A> list;

 void addAll(ArrayList<? extends A> list) {

for(A a: list) {

addElement(a);

}

}


 void addElement(A element) {

list.add(element);

}

}


Does it suit you?



On Tue, Jul 22, 2008 at 2:08 AM, Lachlan Deck <[EMAIL PROTECTED]>
wrote:

> On 22/07/2008, at 7:41 AM, Simon McLean wrote:
>
>  one of the things that frustrates me about generics is working with
>>>> collections.
>>>>
>>>
>>> Just that one? Generics are the worst thing since Windows 3.11 ... I try
>>> to keep my code clean and add generics where they make sense but I hate
>>> them. There is absolutely NO GAIN in using them, just annoyance.
>>>
>>
>> how about being able to do this :-
>>
>> myarray.objectAtIndex(i).getMyKeypath();
>>
>> without having to do a cast ?
>>
>> i luuuuuurrrve generics!
>>
>
> Yeah, but it's implementation in Java sux.
>
> Example:
> NSMutableArray<? extends Foo> foos; // no problem
>
> foos = new NSMutableArray<? extends Foo>(); // can't compile
>
> Just stupid.
>
> with regards,
> --
>
> Lachlan Deck
>
>
>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list      ([email protected])
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/webobjects-dev/shkutkov%40gmail.com
>
> This email sent to [EMAIL PROTECTED]
>



-- 
Cheers, Michael
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to