问题:
Let's say I have a method m() that takes an array of Strings as an argument. 假设我有一个方法m(),该方法将字符串数组作为参数。 Is there a way I can just declare this array in-line when I make the call? 有什么方法可以在我打电话时直接声明该数组? ie Instead of: 即代替:
String[] strs = {"blah", "hey", "yo"};
m(strs);
Can I just replace this with one line, and avoid declaring a named variable that I'm never going to use? 我可以只用一行替换它,而避免声明一个我永远不会使用的命名变量吗?
解决方案:
参考一: https://stackoom.com/question/4qD2/有什么方法可以在线声明数组吗参考二: https://oldbug.net/q/4qD2/Any-way-to-declare-an-array-in-line
来源:oschina
链接:https://my.oschina.net/u/4438370/blog/4278967