Javaの可変長引数を色々。
可変長引数色々。結局は配列になる。
お試しコード
public class Main { public static void main(String[] args) throws Exception { // Your code here! Main main = new Main(); main.hoge("hoge","hige","hage"); } private void hoge(String ... hoges){ System.out.println(hoges.getClass().getName()); for(int i = 0; i < hoges.length; i++){ System.out.println(hoges[i]); } for(String ho: hoges){ System.out.println(ho); } } }
実行結果
[Ljava.lang.String;
hoge
hige
hage
hoge
hige
hage
参考
https://paiza.io/projects/266GxsDaHS0ypsxjC1m8fw?locale=en-us