• Post Reply Bookmark Topic Watch Topic
  • New Topic

Can anyone explain what is the T,  RSS feed

 
jacob deiter
Ranch Hand
Posts: 587
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public abstract class Controller <T> extends Simple {

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

}
Can anyone explain what is the <T>,
 
Pawan Arora
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
T is a template variable
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16007
87
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See Java 5 - Generics.
 
Rob Spoor
Sheriff
Posts: 21048
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
kranthi chamarthi
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Campbell Ritchie
Sheriff
Posts: 55351
157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!