How to sort short Array in Java

1 Answer

0 votes
package javaapplication1;

import java.util.Arrays;

public class JavaApplication1 {

    public static void main(String[] args) {

        short[] sArr = new short[]{6, 7, 3, 2, 9, 8, 1, 5, 4};

        Arrays.sort(sArr);

        for (int i = 0; i < sArr.length; i++) 
            System.out.print(sArr[i] + " ");
    }
}
 
/*

run:

1 2 3 4 5 6 7 8 9

*/

 



answered Oct 6, 2016 by avibootz

Related questions

1 answer 203 views
1 answer 162 views
4 answers 244 views
244 views asked Nov 17, 2023 by avibootz
2 answers 312 views
1 answer 221 views
...