Results 1 to 6 of 6
Thread: Arrowhead brackets
- 02-13-2010, 09:22 AM #1
Member
- Join Date
- Feb 2010
- Posts
- 5
- Rep Power
- 0
- 02-13-2010, 11:20 AM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,385
- Blog Entries
- 7
- Rep Power
- 17
That is an example of Java Generics. It helps the programmer in compile time type safety (C++ has a similar looking feature 'class templates' but both are entirely different mechanisms).
kind regards,
Jos
- 02-14-2010, 03:44 AM #3
Senior Member
- Join Date
- Mar 2009
- Posts
- 552
- Rep Power
- 5
Well, aside from the typical less than (<) and greater than(>) operations, it is generics. A generic argument is used to create classes that provide functionality for any objects or for any objects derived from a specific type. They are similar to C++ class templates, but while C++ creates completely separate classes for each generic/template argument used, Java does not - which means that you cannot create arrays of the generic argument, or cast anything to the generic argument type.
A full tutorial is here - Java GenericsIf the above doesn't make sense to you, ignore it, but remember it - might be useful!
And if you just randomly taught yourself to program, well... you're just like me!
- 02-14-2010, 05:03 AM #4
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,540
- Rep Power
- 11
List<Book> b=new ArrayList<Book>();
This is read "list of books b is a new array list of books".
Generics is the ability to have lists (/maps/sets etc) of something. You use a line like the one to posted to declare and create them. And the compiler will complain if you try and use a member of the list as anything but a reference to a Book instance.
- 02-14-2010, 09:06 AM #5
Member
- Join Date
- Feb 2010
- Posts
- 5
- Rep Power
- 0
Thanks
Thanks JosAH, it was helpfull:)
- 02-14-2010, 09:08 AM #6
Member
- Join Date
- Feb 2010
- Posts
- 5
- Rep Power
- 0
Similar Threads
-
Bracket help - can't find the missing brackets.
By Z E P H Y R in forum New To JavaReplies: 0Last Post: 03-17-2009, 10:26 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks