Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / September 2006

Tip: Looking for answers? Try searching our database.

a simple question

Thread view: 
Shawn - 12 Sep 2006 16:35 GMT
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



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.