[英]Not able to understand a complex parameterized return type - Java
I have come across a snippet similar to this in Java 我遇到了一个类似于Java的代码段
public <H extends ABC<I, U>, I, U> Set<U> get(Type<H, I, U> type) {
}
I do not understand this. 我不明白这个。 I only understand that it takes a parameter of the parameterized type
Type<H,I,U>
and that it returns a Set<U>
which is the return type. 我只了解它接受参数化类型
Type<H,I,U>
的参数,并且返回Set<U>
这是返回类型。 But, I do not understand the part: 但是,我不了解该部分:
<H extends ABC<I,U>, I,U>
Can anybody clarify it? 有人可以澄清吗?
Regards, Chetan 问候,车丹
It means that 这意味着
H
, I
, and U
H
, I
和U
I
and U
can be anything I
和U
可以是任何东西 H
must extend ABC<I, U>
(or it can actually be ABC<I, U>
) H
必须扩展ABC<I, U>
(或者实际上可以是 ABC<I, U>
) So presumably you have a type ABC
which has two type parameters. 因此,假设您有一个具有两个类型参数的
ABC
类型。 This is saying that, for instance, this would be valid: 这就是说,例如,这将是有效的:
Type<ABC<String, Date>, String, Date> type = new Type<>();
Set<String> set = instance.get(type);
...because there H
would be ABC<String, Date>
, I
would be String
, and U
would be Date
. ...因为
H
将是ABC<String, Date>
, I
将是String
,而U
将是Date
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.