java - sorting an array in the same line as instantiation/initialization -
if given array of ints
:
int[] age = new int [] {32, 25, 56, 56, 12, 20, 22, 19, 54, 22};
is there way sort(lowest-highest) in same line instantiation/initialization, elements of age be: 12, 19, 20, 22...
?
not same line.
but can do:
public static int[] sort(int[] a) { arrays.sort(a); return a; } // ... int[] age = sort(new int[] {32, 25, 56, 56, 12, 20, 22, 19, 54, 22});
Comments
Post a Comment