Declare Multiple Java Arrays on Same Line? -
is possible initialize and/or declare multiple arrays in same line in java?
ie.
int a, b, c, d, e = 4
works but
int[] a, b, c, d, e, = new int[4]
doesn't seem work (size of array 4)
bear in mind
int a, b, c, d, e = 4;
is declaring 5 ints initialising 'e'.
in same way,
int[] a, b, c, d, e = new int[4];
will initialise e.
you'd need
int[] a=new int[4], b=new int[4], etc...
which frankly, isn't worth one-lining...
Comments
Post a Comment