如何手动将变量分配给数组?我在下面有一个代码片段.我不想手动放shortStraight[0] = "211100", shortStraight[1] = "021110",等等.有帮助吗?
private String [] shortStraight;
public Sample () {
shorty = new String [12];
shorty = {211100, 021110, 002111, 121100, 112100, 111200, 012110, 011210, 011120, 001211, 001121, 001112 } //this line doesn't work.
Run Code Online (Sandbox Code Playgroud)
有帮助吗?
String[] shorty = {"211100", "021110", "002111", "121100", "112100", "111200", "012110", "011210", "011120", "001211", "001121", "001112"} ;
Run Code Online (Sandbox Code Playgroud)
http://download.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html
String[] shorty = {"211100", "021110", "002111", "121100", "112100", "111200", "012110", "011210", "011120", "001211", "001121", "001112"} ;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9125 次 |
| 最近记录: |