Java Collection Tutorial - Java Arrays.sort(short[] a)








Syntax

Arrays.sort(short[] a) has the following syntax.

public static void sort(short[] a)

Example

In the following code shows how to use Arrays.sort(short[] a) method.

//w w w . j  av  a 2s.c o m
import java.util.Arrays;

public class Main {

   public static void main(String[] args) {

    // initializing unsorted short array
    short sArr[] = {212, 1, 19, 2, 5};

    System.out.println(Arrays.toString(sArr));

    // sorting array
    Arrays.sort(sArr);

    System.out.println(Arrays.toString(sArr));
  }
}

The code above generates the following result.