Why are generics called generics?

后端 未结 9 844
野性不改
野性不改 2021-02-04 00:48

At the risk of becoming the village idiot, can someone explain to me why generics are called generics? I understand their usage and benefits, but if the definition of generic i

9条回答
  •  情书的邮戳
    2021-02-04 01:37

    bool Equals(int x, int y)
    

    The above method can only compare integers, so we can say that it is specialized for comparing integers.

    bool Equals(T x, T y);
    

    The above method can compare values of any type, so we can say that it isn't specialized for any particular type - it's generic.

提交回复
热议问题