有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!


共 (6) 个答案

  1. # 1 楼答案

    三个点称为省略号。方法可以调用任意数量的Context类型的值。您也可以不带值地调用该方法

  2. # 2 楼答案

    它是Java5中引入的varargs。更多信息请访问Varargs

  3. # 3 楼答案

    这意味着您可以设置一系列值:

    onProgessUpdate(c1,c2,c3);
    
  4. # 4 楼答案

    一个词:^{}.

    The three periods after the final parameter's type indicate that the final argument may be passed as an array or as a sequence of arguments. Varargs can be used only in the final argument position.

  5. # 5 楼答案

    它们被称为varargs,是在Java5中引入的。阅读http://download.oracle.com/javase/1.5.0/docs/guide/language/varargs.html了解更多信息

    简而言之,它允许在不必创建数组的情况下将数组传递给方法,就好像该方法采用了数量可变的参数一样。在您的示例中,以下四个调用是有效的:

    onProgressUpdate();
    onProgressUpdate(context1);
    onProgressUpdate(context1, context2, context3);
    onProgressUpdate(new Context[] {context1, context2});
    
  6. # 6 楼答案

    这意味着values参数是Context对象的可选数组。因此,您可以通过以下方式调用“onProgressUpdate”函数:

    onProgressUpdate(); // values is an empty array.
    onProgressUpdate(new Context[] { new Context() }); // values has one item.
    onProgressUpdate(context1, context2); // values has two items.
    

    请参阅Java1.5中引入的varargs语言特性