Java - pass in array values -
is possible pass in array values?
test ([1, 2, 3, 4]); public void test(int[] foo) { (int : foo) { system.out.println(i); } } outputs:
1 2 3 4
sure - need create new array in calling code:
test(new int[] { 1, 2, 3, 4 }); or change method declaration use varargs parameter:
public void test(int... foo) and call with:
test(1, 2, 3, 4);
Comments
Post a Comment