'Fruit ...'是Java命名约定中的有效类名吗?(Is 'Fruit…' a valid class name in Java Naming convention?)
我是Java的初学者,在我探索的过程中,我看到了一个代码,它的用法是Fruit... fruitName ? 我曾经在任何文档中看到过这样的用法,比如...
任何人都可以知道这个用途是什么以及如何使用?
I'm a beginner in Java, and while I was exploring I got to see a code which has the usage as Fruit... fruitName? I have ever seen such a usage in any documentation like ...
Can anyone know what and how the usage of this?
最满意答案
class Fruit { // Class implementation } public void extractJuice(Fruit... args) { // This method can take variable arguments of type Fruit }所以你所看到的是变量参数的缩写。
其他参考文献: - 你什么时候在Java中使用varargs?
class Fruit { // Class implementation } public void extractJuice(Fruit... args) { // This method can take variable arguments of type Fruit }So what you are looking at is varargs short for Variable Arguments.
Futher references: - When do you use varargs in Java?
更多推荐
发布评论