• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Can anyone explain what is the T,

 
Ranch Hand
Posts: 594
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
public abstract class Controller <T> extends Simple {

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

}
Can anyone explain what is the <T>,
 
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
T is a template variable
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
See Java 5 - Generics.
 
Sheriff
Posts: 22801
131
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Marshal
Posts: 79701
381
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Destroy anything that stands in your way. Except this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic