What does T mean when used as a method signature? Is it a return type?

前端 未结 2 782
臣服心动
臣服心动 2021-01-14 09:47
abstract public  T iterEdges(EdgeFun func, T accum);

This is for a multithreaded library for graphs. I am not asking for anything

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-14 10:45

    T is a generic type. It allows generic type invocation when using the class in actual code.

    You may have also seen in hash maps. Below is the legend for other parameters

    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

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

提交回复
热议问题