对java中方法参数中出现...的理解

其中...表示可以有多个(0,1,2,...)Class<?>类型的对象。

类似于Class<?>[],但是又不同于数组。

理解如下:

例如:

void hello(String[] args);

void hello(String... args);

当参数个数为0时,前者的调用为hello(null);

而后者的调用方式为hello();

猜你喜欢

转载自blog.csdn.net/bird_a_java/article/details/80082389