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








Syntax

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

public static void sort(long[] a)

Example

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

/*from  w  w  w  .  j  av a 2 s. co  m*/

import java.util.Arrays;

public class Main {

   public static void main(String[] args) {

    // initializing unsorted long array
    long lArr[] = {221, 10, 111, 62, 46};

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

    // sorting array
    Arrays.sort(lArr);

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

The code above generates the following result.