Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to manually set an array in Java?

Tags:

java

How do you manually assign variables to an array? I have a code fragment below. I don't want to manually put shortStraight[0] = "211100", shortStraight[1] = "021110", and so on. Any help?

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.

Any help?

like image 863
yuritsuki Avatar asked Dec 17 '22 08:12

yuritsuki


2 Answers

String[] shorty = {"211100", "021110", "002111", "121100", "112100", "111200", "012110", "011210", "011120", "001211", "001121", "001112"} ;
like image 182
claymore1977 Avatar answered Dec 27 '22 23:12

claymore1977


String[]   shorty = {"211100", "021110", "002111", "121100", "112100", "111200", "012110", "011210", "011120", "001211", "001121", "001112"} ;

http://download.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html

like image 23
PeterMmm Avatar answered Dec 27 '22 23:12

PeterMmm