Hi,
I am reading some Java file, which I don't understand:
Class A<B> {
B b;
A(B b) {this.b = b;}
...
} //A
A<JComponent> = new A(JButton);
I have never seen <..> after a Class name, like Class A<B>. I guess this
is some template stuff, similar to C++. Is this something new for Java
1.5 or I just didn't know before?
Thank you.
Tim Ward - 12 Sep 2006 16:40 GMT
> I have never seen <..> after a Class name, like Class A<B>. I guess this
> is some template stuff, similar to C++. Is this something new for Java
> 1.5
Yes.
--
Tim Ward
Brett Ward Limited - www.brettward.co.uk
Shawn - 12 Sep 2006 16:55 GMT
>> I have never seen <..> after a Class name, like Class A<B>. I guess this
>> is some template stuff, similar to C++. Is this something new for Java
[quoted text clipped - 5 lines]
> Tim Ward
> Brett Ward Limited - www.brettward.co.uk
Can you point to me where to pick it up? What is it for? How to use it?
Thank you.
Tor Iver Wilhelmsen - 12 Sep 2006 17:01 GMT
> Can you point to me where to pick it up? What is it for? How to use it?
It's to get compile-time type safety. It all gets turned into Object
and casts in the end.
http://java.sun.com/developer/technicalArticles/J2SE/generics/index.html
Daniel Dyer - 12 Sep 2006 22:33 GMT
>> Can you point to me where to pick it up? What is it for? How to use it?
>
> It's to get compile-time type safety. It all gets turned into Object
> and casts in the end.
>
> http://java.sun.com/developer/technicalArticles/J2SE/generics/index.html
Also
http://java.sun.com/j2se/1.5/pdf/generics-tutorial.pdf
Dan.

Signature
Daniel Dyer
http://www.dandyer.co.uk