20210718 TIL

김진태·2021년 7월 18일
0

public class Test {
    static String test(String... str) {
        String a = "";
        for(String  s: str){
             System.out.print(s);
		}
        return a;
    }

    public static void main(String[] args) {
        test("a","b","c","d");
    }
}

이런 문법이 있었다니...

  • 가변인수는 파라미터의 마지막에만 올 수 있다.
  • String으로도 받을 수 있고 List< String>으로도 받을 수 있다.!
profile
안녕!

0개의 댓글