0

This is one of my interview question.

Why the datatype is denoted by the letter in generics and why not some other letter/alphabet.

user207421
  • 305,947
  • 44
  • 307
  • 483
user2059013
  • 117
  • 1
  • 1
  • 6
  • 1
    The T is for Type. – jmcilhinney Jun 01 '16 at 03:08
  • T is a user-defined name in the languages I know... it could just as well be `Type` or `Whatever_the_programmer_wanted_to_call_it`. For example, in the D standard library, it is often `Range` because these functions accept a generic range type instead of just anything. – Adam D. Ruppe Jun 01 '16 at 03:09
  • 5
    A [quick search of SO](http://stackoverflow.com/search?q=generic+letter+t) turns up [Why do generics often use T?](http://stackoverflow.com/questions/374014/why-do-generics-often-use-t) as the #1 hit. – Raymond Chen Jun 01 '16 at 03:52
  • Basically just repeating what the comments to the question already said: T is commonly used because it means Type, but all programming languages I know of allow you to specify your own names for generic type parameters, just like you can with variables, class names, method/function names, etc. – Nyde Jul 26 '20 at 18:56

0 Answers0