Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Java中手动设置数组?_Java - Fatal编程技术网

如何在Java中手动设置数组?

如何在Java中手动设置数组?,java,Java,如何手动将变量分配给数组?我在下面有一个代码片段。 我不想手动放置shortStraight[0]=“211100”、shortStraight[1]=“021110”,等等。有什么帮助吗 private String [] shortStraight; public Sample () { shorty = new String [12]; shorty = {211100, 021110, 002111, 121100, 112100

如何手动将变量分配给数组?我在下面有一个代码片段。 我不想手动放置
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.
有什么帮助吗

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.
String[]   shorty = {"211100", "021110", "002111", "121100", "112100", "111200", "012110", "011210", "011120", "001211", "001121", "001112"} ;

投票结束,这太简单了(谷歌-“java初始化字符串数组”)嗯…哪一个?你的两个答案都不一样。这是一个合理的问题,即使在你看来这“太容易了”。