• Post Reply Bookmark Topic Watch Topic
  • New Topic

Generics -- what is T, or E ?  RSS feed

 
Ranch Hand
Posts: 94
1
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
interface Computation<T>

Hi
can anyone tell me what T means or indicate, i know generics with <String> <Number> <Integer> and other....
But what does <T>,<E>,<V> means,what type are those?
Thank you
 
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
 
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's the name of the type parameter.

In your example, class Computation has one type parameter, which is named T. Type parameters are conventionally named with single, upper-case letters, but you could in principle use any valid name for them (I advise you to stick to single, upper-case letters, because almost everybody does it that way).

When you eventually use class Computation somewhere, you're going to use it with a specific, concrete type (for example, String or Integer).

It's a little bit like how methods are declared and called. In the declaration of the method, you have parameter variables, and when you call the method, you're filling in those parameters with specific values.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!