此方法签名中的省略号 (...) 是什么? [英] What is the ellipsis (...) for in this method signature?

查看:38
本文介绍了此方法签名中的省略号 (...) 是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

App Engine 中docs,此方法签名中的省略号 (JID...) 是什么?

In the App Engine docs, what is the ellipsis (JID...) for in this method signature?

public MessageBuilder withRecipientJids(JID... recipientJids)

这三个点的作用是什么?

What's the function of those three dots?

推荐答案

那些是 Java 可变参数.它们允许您传递任意数量的特定类型的对象(在本例中它们是 JID 类型).

Those are Java varargs. They let you pass any number of objects of a specific type (in this case they are of type JID).

在您的示例中,以下函数调用是有效的:

In your example, the following function calls would be valid:

MessageBuilder msgBuilder; //There should probably be a call to a constructor here ;)
MessageBuilder msgBuilder2;
msgBuilder.withRecipientJids(jid1, jid2);
msgBuilder2.withRecipientJids(jid1, jid2, jid78_a, someOtherJid);

在此处查看更多信息:http://java.sun.com/j2se/1.5.0/docs/guide/language/varargs.html

这篇关于此方法签名中的省略号 (...) 是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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