我看到有人在java中初始化和数组如此
int[] s;
s = new int[]{ and put the list here..}
Run Code Online (Sandbox Code Playgroud)
与
int[] s = { the list here}
Run Code Online (Sandbox Code Playgroud)
这些都是可以接受的方式吗?
是的,两者都是创建java整数数组的同等有效方法.第二个版本只是第一个版本的快捷语法.
更多相关内容:http://download.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html