什么< T> T意味着什么时候用作方法签名?它是返回类型吗? [英] What does <T> T mean when used as a method signature? Is it a return type?

查看:141
本文介绍了什么< T> T意味着什么时候用作方法签名?它是返回类型吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

abstract public <T> T iterEdges(EdgeFun<T> func, T accum);

这是用于图形的多线程库。我不是在要求任何与实际实现相关的东西,我只是不明白双重返回类型是什么意思?

This is for a multithreaded library for graphs. I am not asking for anything pertinent to actual implementation whatsoever, I just don't understand what the double return types mean?

我只是在这里猜测,但这是我的解释(我尝试了谷歌搜索,但谷歌不匹配非字母数字符号,所以我尝试了几个术语的组合,但没有得到任何地方。)

I am just guessing here, but this is my interpretation (I tried googling, but Google doesn't match on non alphanumeric symbols, so I tried a few combinations of terms but didn't get anywhere.)

它是只是说它会返回某种T型的集合?两个类扩展了这个方法被发现的类,所以我想它允许多态性,但是这个的真正含义是什么?

It is just saying that it will return some kind of collection of T type? Two classes extend the class that this method is found within, and so I guess it allows for polymorphism, but what is the true meaning of this?

推荐答案

它是一个泛型方法。第一种是使用通用类型。该函数还声明返回该类型为T.参数表明它们使用该泛型参数类型。

It is a generic method. The first is for the generic type that would be used. The function is also declaring that is returns that type T. The parameters are showing that they use that generic parameter type.

这篇关于什么&lt; T&gt; T意味着什么时候用作方法签名?它是返回类型吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆