-2

It might be a very beginner question, but I'm curious to ask. Usually I use <T> to write a generic Java class.

public class Foo<T> extends Bar<T> {...}

But I also see people use <E> in many open source project. Does <E> imply anything different from <T>? Or it is just some coding habits?

stanleyxu2005
  • 8,081
  • 14
  • 59
  • 94
  • it's just coding habits. some may say T stands for type and E stands for Entity, or whatever, you can use any letter you want. – Leo Aug 09 '14 at 14:46

2 Answers2

3

It doesn't make a difference, but these are the most common names:

http://docs.oracle.com/javase/tutorial/java/generics/types.html

The most commonly used type parameter names are:

  • E - Element (used extensively by the Java Collections Framework)
  • K - Key
  • N - Number
  • T - Type
  • V - Value
  • S,U,V etc. - 2nd, 3rd, 4th types
Community
  • 1
  • 1
August
  • 12,410
  • 3
  • 35
  • 51
2

<E> usually means an Element unlike <T> which means a Type. Check Generics here. This is just a convention.

Peter O.
  • 32,158
  • 14
  • 82
  • 96
TheLostMind
  • 35,966
  • 12
  • 68
  • 104