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

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -