java中数组和3点(Varargs)之间的差异 [英] Difference between Arrays and 3 dots (Varargs) in java
本文介绍了java中数组和3点(Varargs)之间的差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我无法弄清楚java和数组中的 ...
之间的区别是数组列表,尤其是数组列表。
I cannot figure out that what are the differences between ...
in java and arrays also array list, especially array list.
我们都可以使用无限制,但很少使用 ...
。
Both we can use as unlimited but ...
is rarely used.
请帮忙提前谢谢。
推荐答案
三个点只能在方法参数中使用,称为varargs。这意味着您可以在不显式创建数组的情况下传入参数数组。
The three dots can only be used in a method argument, and are called 'varargs'. It means you can pass in an array of parameters without explicitly creating the array.
private void method(String [] args){}
被称为方法(new String [] {first,second});
private void方法(String ... args){}
被调用为方法(first,second);
这篇关于java中数组和3点(Varargs)之间的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文