Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can anyone explain what is the T,

 
jacob deiter
Ranch Hand
Posts: 584
  • 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
Saloon Keeper
Posts: 15214
36
Android IntelliJ IDE Java Scala Spring
 
Rob Spoor
Sheriff
Pie
Posts: 20510
54
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: 95
  • 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: 48645
56
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic