Skip to content
Advertisement

What is the difference between “ T” and “T” return types in JavaDocs

Still wrapping my head around generics so help would be appreciated.

Advertisement

Answer

In both cases, the return type is T.

If you see <T> before though, it means that the generic type T has been defined at the method level:

JavaScript

If not, then it has probably been defined at the class level:

JavaScript

Or, it can technically also simply be a class named T, although those single-letter types usually refer to generics (purely by convention):

JavaScript

Note that you don’t have to use T as the return type:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement