> public class A<T>
> {
[quoted text clipped - 17 lines]
> wildcards.
> I am not 100% clear with generic - Is it possible at all??
If I understand you correctly, then no it's not possible, at least
without warnings. That's because it's not type-safe. You are basically
saying that you want B to not keep track of the type parameter, and then
be able to return the object as if it had any type parameter and have
the compiler be okay with it. That's exactly the kind of problem that
generics were meant to solve. You certainly can do this:
public class B
{
A<?> a;
public A<?> getA() { return a; }
}
That's okay because you aren't pretending to know anything about a.
And, of course, you can do this:
public class B<T>
{
A<T> a;
public A<T> getA() { return a; }
}
That's okay because you really do know something about a. The only
thing that's truly impossible is to throw away knowledge of a's type,
and then go on as if you still know it by trying to return a as a
specific type.
What you're attempting is actually somewhat close to capture conversion.
If you had an a for which you don't know the type argument, you can
introduce an arbitrary type name to represent it for the purposes of a
calculation. However, you can't then return something typed with that
arbitrary name, since the name is meaningless outside of the method
which resulted in use of capture conversion.

Signature
Chris Smith - Lead Software Developer / Technical Trainer
MindIQ Corporation
nramnath@gmail.com - 04 Jul 2006 08:24 GMT
Hai,
Thanks for the reply. I too know about that, but just wanted to
confirm.
Thanks
Ramnath
> > public class A<T>
> > {
[quoted text clipped - 55 lines]
> Chris Smith - Lead Software Developer / Technical Trainer
> MindIQ Corporation