This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes what is this line mean: Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "what is this line mean:" Watch "what is this line mean:" New topic

what is this line mean:

Tal Goldstein

Joined: Apr 16, 2006
Posts: 14
public class DelayQueue<E extends Delayed>

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

Vassili Vladimir
Ranch Hand

Joined: Mar 08, 2007
Posts: 1585

Check this.

Best of luck ...

Vassili ...
SCJP 5.0, SCWCD 1.4, SCJA 1.0
David Irwin
Ranch Hand

Joined: Mar 25, 2004
Posts: 82
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.

With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: what is this line mean: