This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what is this line mean:

 
Tal Goldstein
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public class DelayQueue<E extends Delayed>

what the <> does?
and where can i read about it?

thanks
 
Vassili Vladimir
Ranch Hand
Posts: 1585
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Check this.

Best of luck ...
 
David Irwin
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As Vassili pointed out, the <> are used in Generics, a language addition in Java version 1.5. It essentially allows the developer to create type declarations. I have found this especially helpful in the Collections framework. For example before 1.5 you might do something like the following:



Notice that I have to cast the return object from an Object to an Item. In Java 1.5 and later you can declare a list of a specific type:



See how you don't need to cast from an Object to an Item. And it also prevents non-Item type objects from being added to the list. Type safety is generally increased.

You might also check out the following tutorial: tutorial.

Dave
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic