Question on generics

0 views
Skip to first unread message

Dimitris Andreou

unread,
Dec 3, 2009, 4:11:16 PM12/3/09
to Google Collections Library - users list
Hi,

Sorry, this question isn't related to google collections, but I figure
there are many generics experts listening. I want to verify whether,
given this definition:

interface X<T extends X<T>> { }

One could declare a variable of type X.

X<...> var = null;

Can someone replace the "..." with something, without using "?", and
have it compile without errors/warnings?

The only way I can do it is by cheating:

<T extends X<T>> void method(T t)
X<T> x = null; //this compiles
}

But then I don't know how to call this method without errors/warnings :)

Could this be impossible??

Thanks,
Dimitris

Dimitris Andreou

unread,
Dec 3, 2009, 5:03:52 PM12/3/09
to Google Collections Library - users list
Forwarding this so nobody else bothers to answer, thanks again :)

Regards,
Dimitris

---------- Forwarded message ----------
From: Nikolas Everett <nik...@gmail.com>
Date: 2009/12/3
Subject: Re: [google-collections] Question on generics
To: Dimitris Andreou <jim.a...@gmail.com>


This compiles:

interface X<T extends X<T>> { }

class Y implements X<Y> { }

public void main() {
  X<Y> x = null;
> --
> Google Collections Library - users list
> http://groups.google.com/group/google-collections-dev?hl=en
>
> To unsubscribe, send email to:
> google-collections...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages