*
The moose likes Beginning Java and the fly likes Can anyone explain what is the T, Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Can anyone explain what is the T," Watch "Can anyone explain what is the T," New topic
Author

Can anyone explain what is the T,

jacob deiter
Ranch Hand

Joined: Apr 02, 2008
Posts: 576
public abstract class Controller <T> extends Simple {

��������
��������..

}
Can anyone explain what is the <T>,
Pawan Arora
Ranch Hand

Joined: Sep 14, 2008
Posts: 105
T is a template variable
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14116
    
  16

See Java 5 - Generics.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19684
    
  20

Jacob,

I suggest you do some searching whenever you think of a question. Quite a lot of your questions have answers that can easily be found on this board, on Wikipedia, in the Java Language Specification or Google. In other words: Search First.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
kranthi chamarthi
Ranch Hand

Joined: May 08, 2007
Posts: 95
T indicates Generic. Prior to java 5 when we use collections we used to specify it like
List k=new ArrayList();
There is no restriction on what you can add and what you cant add into list. You can add any type of Object into the list.
So Generics will allow you to specify what type of objects you can add into a collection.
List<Animal> k=new ArrayList<Animal>();
Now this indicates that you can add Objects of type Animal into the collection, you cannot add objects of type Human or Vehicle into it.
Generics allows to code type safe collections.
Here T indicates a Generic Type.
Hope you find it useful.
Gyanendra Gupta
Greenhorn

Joined: Oct 22, 2008
Posts: 1
Originally posted by kranthi kumar.chamarthi:
T indicates Generic. Prior to java 5 when we use collections we used to specify it like
List k=new ArrayList();
There is no restriction on what you can add and what you cant add into list. You can add any type of Object into the list.
So Generics will allow you to specify what type of objects you can add into a collection.
List<Animal> k=new ArrayList<Animal>();
Now this indicates that you can add Objects of type Animal into the collection, you cannot add objects of type Human or Vehicle into it.
Generics allows to code type safe collections.
Here T indicates a Generic Type.
Hope you find it useful.


If you ever feel like working hard.......sit back......until you get rid of that dangerous feeling.....
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38509
    
  23
Welcome to JavaRanch, Gyanendra Gupta.

But please don't simply quote somebody else's post like that; you ought to have something to add to it.
 
wood burning stoves
 
subject: Can anyone explain what is the T,