• Post Reply Bookmark Topic Watch Topic
  • New Topic

meaning of angle brackets in java library  RSS feed

 
Sam Smythe
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I notice that some of the classes in the library have <E> after them and am not sure what it means. I have seen some of them used with <type or types inside>. What does that type of bracketing mean and what is the E?
 
Scott Johnson
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The angle brackets are for generics, a feature introduced in Java 5.

One benefit of generics is that they allow you to tell the compiler what kind of objects should be in a collection. That allows the compiler to watch for type mis-matches and turns run-time errors into compile-time errors.

Take a look at the Sun's Generics Tutorial for more details.
[ August 01, 2006: Message edited by: Scott Johnson ]
 
Sam Smythe
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you so much. Once I knew what they were called, I even found a great tutorial on how to use them and it solved many of my problems with my code.
 
Scott Johnson
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Great! If you can, please post the link to the tutorial. I'm sure there are a lot of JavaRanch readers that could benefit from it.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!