Off-topic: Java Reflection/Generics/Collections question
npacemo at gmail.com
Fri Dec 26 18:32:47 UTC 2008
What you try to do is not a valid operation in type-safe language as Java.
You can't convert Coll to Coll<ItemType>,
but you can cast Coll<?> to Coll<Whatever>.
Don't know if this is OK with the problem you're trying to solve
On Fri, Dec 26, 2008 at 4:20 PM, Frank Staals <frankstaals at gmx.net> wrote:
> Not realy a FreeBSD-specific question but I was not sure where I could find
> what I was looking for elseware (Googling did not manage to dig up much
> The problem:
> I want to set the type of objects some Collection object holds on runtime.
> In other wors I have an object C with: C extends AbstractCollection, I have
> the Class object T specifying what type of objects C should hold and I have
> a method M which takes a C<T> as an argument. I made a generic version of C
> (without the type) and now I have to set it so it can only carry objects of
> type T. Does anyone know how to do this ?
> Information in programming style:
> C extends AbstractCollection myCollection;
> Class itemType;
> public void myMethod(C<itemType> myCollectionArgument)
> How do I convert myCollection from being a C to a C<itemType> on runtime
> so I can call myMethod(myCollection) ?
> I hope the explanation of my problem makes sense and someone can help me.
> - Frank
> freebsd-questions at freebsd.org mailing list
> To unsubscribe, send any mail to "
> freebsd-questions-unsubscribe at freebsd.org"
More information about the freebsd-questions