[英]Generics return type E
What is return type E in the following code 以下代码中的返回类型E是什么
public E get(int index) {
synchronized (mutex) {
return super.get(index);
}
}
Java doc says it's an Element. Java文档说这是一个元素。 But i didn't get it correctly.
但是我没有正确地得到它。 It's helpful if i get explanation with an example.
如果我得到一个例子的解释会很有帮助。
It's whatever you say it is. 随你怎么说。 If you have a
Mutex<Integer>
then it's an Integer
. 如果您有
Mutex<Integer>
则它是Integer
。 If you have a Mutex<String>
then it's a String
. 如果您有
Mutex<String>
String
。 If you have a Mutex<Cheeseburger>
then it's a Cheeseburger
. 如果您有
Mutex<Cheeseburger>
则它是Cheeseburger
。 E
is a special kind of variable , sort of like int index
in your example. E
是一种特殊的变量 ,在您的示例中有点像int index
。 The difference is that E
takes on types, not values. 区别在于
E
类型,而不是值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.