java参数类型中的这三个点是什么
Possible Duplicate:
What is the ellipsis for in this method signature?
例如:protected void onProgressUpdate(Context... values)
你可以在下面搜索框中键入要查询的问题!
Possible Duplicate:
What is the ellipsis for in this method signature?
例如:protected void onProgressUpdate(Context... values)
# 1 楼答案
三个点称为省略号。方法可以调用任意数量的Context类型的值。您也可以不带值地调用该方法
# 2 楼答案
它是Java5中引入的
varargs
。更多信息请访问Varargs# 3 楼答案
这意味着您可以设置一系列值:
# 4 楼答案
一个词:^{}.
# 5 楼答案
它们被称为varargs,是在Java5中引入的。阅读http://download.oracle.com/javase/1.5.0/docs/guide/language/varargs.html了解更多信息
简而言之,它允许在不必创建数组的情况下将数组传递给方法,就好像该方法采用了数量可变的参数一样。在您的示例中,以下四个调用是有效的:
# 6 楼答案
这意味着
values
参数是Context
对象的可选数组。因此,您可以通过以下方式调用“onProgressUpdate”函数:请参阅Java1.5中引入的varargs语言特性