有什么方法可以在线声明数组吗?

一个人想着一个人 提交于 2020-07-28 17:31:26

问题:

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
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!