Dav*_*vid -1 java arrays variables
在java中你可以有一个变量数组吗?
如果是的话语法是什么?
这是一个例子,如果你困惑:
varint[] ArrayOfVariablesThatAreInts = new varint[#]
Run Code Online (Sandbox Code Playgroud)
要么
var[] ArrayofVariables = new var[#]
Run Code Online (Sandbox Code Playgroud)
这是合法的吗?
是的你可以使用:
Foo[] arrFoo = new Foo[10];
arrFoo[0] = new Foo();
..
Run Code Online (Sandbox Code Playgroud)
或者,如果您不想定义修复大小,可以使用ArrayList:
List<Foo> arrFoos = new ArrayList<Foo>();
arrFoos.add(new Foo());
..
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
15881 次 |
| 最近记录: |