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








Syntax

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

public static void sort(char[] a)

Example

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

//w w w  .ja v  a  2 s . co m
import java.util.Arrays;

public class Main {

   public static void main(String[] args) {

    char cArr[] = {'j','a','v','a'};

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

    // sorting array
    Arrays.sort(cArr);

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

The code above generates the following result.