Java multiple arguments dot notation - Varargs(Java 多参数点表示法 - Varargs)
问题描述
我刚刚承认带有多个参数的方法声明的点表示法
像这样:
I've just acknowledged dot notation for method declaration with multiple arguments
like this:
public function getURLs(URL... urls){
for(int i = 0; i < urls.length; i++){
// walk through array of arguments
}
}
这样使用
getURLs(url1, url2, url3);
这些方法参数被隐式转换为 URL[] urls
where those method arguments are converted implicitly into URL[] urls
- 我是否正确理解了它的行为?
- 此语法的文档在哪里?
- 支持哪个版本的 JRE(J2ME、J2SE、Dalvik)?
推荐答案
是的,它就是这样工作的.参数会自动放入数组中.参数urls"的行为类似于 URL[].此处记录了可变参数.它们是在 Java 1.5 中引入的,因此在 J2SE 1.5+ 和所有 Android 中都可用,因为它支持 Java 1.5+ 语言功能.没有任何版本的 JavaME/J2ME 支持它.
Yes, that is how it works. The arguments are automatically put into an array. The argument "urls" behaves like a URL[]. Varargs are documented here. They were introduced in Java 1.5, so, are available in J2SE 1.5+, and all of Android since it supports Java 1.5+ language features. No version of JavaME/J2ME supports it.
这篇关于Java 多参数点表示法 - Varargs的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Java 多参数点表示法 - Varargs
基础教程推荐
- 使用堆栈算法进行括号/括号匹配 2022-01-01
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- 如何对 Java Hashmap 中的值求和 2022-01-01
- 存储 20 位数字的数据类型 2022-01-01
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- RabbitMQ:消息保持“未确认"; 2022-01-01
- Struts2 URL 无法访问 2022-01-01
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
- 修改 void 函数的输入参数,然后读取 2022-01-01
