Object ... args的正确术语 [英] Proper terminology for Object... args

查看:1058
本文介绍了Object ... args的正确术语的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Java,并且为方法指定多个args的典型方法是:

I'm working in Java and the typical way you specify multiple args for a method is:

public static void someMethod(String[] args)

但是,我已经看过几次,即使是在标准Java库。我不知道如何在谈话中提及这一点,并且由于使用的字符,谷歌搜索没有多大帮助。

But, I've seen another way a few times, even in the standard Java library. I don't know how to refer to this in conversation, and googling is not of much help due to the characters being used.

public static void someMethod(Object... args)

我知道这可以让你串起一串或者在不事先知道确切数量的情况下进入方法的参数,例如:

I know this allows you to string a bunch or arguments into a method without knowing ahead of time exactly how many there might be, such as:

someMethod(String arg1, String arg2, String arg3, ... etc

您如何引用此类方法签名设置?我认为这很好,很方便,并希望向其他人解释,但我不知道如何引用它。谢谢。

How do you refer to this type of method signature setup? I think it's great and convenient and want to explain it to some others, but am at a lack of how to refer to this. Thank you.

推荐答案

这种表达参数的方式称为 varargs ,并在Java 5中引入。

您可以阅读更多关于它们的信息其他

This way to express arguments is called varargs, and was introduced in Java 5.
You can read more about them here.

这篇关于Object ... args的正确术语的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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