开发者

how to pass an array as argument in java (one line only)?

开发者 https://www.devze.com 2023-03-16 03:15 出处:网络
In ruby it would look like myfunction ([\"element1\", \"element2\", \"element3\"],\"other argument\") Can I do the same in java? One line only.

In ruby it would look like

myfunction (["element1", "element2", "element3"],"other argument")

Can I do the same in java? One line only.

I know I can use

    开发者_高级运维    String[] dataToPass = new String[3];
        dataToPass[0] = "element1";
        dataToPass[1] = "element2";
        dataToPass[2] = "element3";
        myfunction(dataToPass,"other argument");


myfunction(new String[]{"e1", "e2", "e3"},"other argument");
0

精彩评论

暂无评论...
验证码 换一张
取 消