Return to Snippet

Revision: 68740
at February 18, 2015 13:51 by nulldev


Initial Code
import java.util.Arrays;

public class ArrayDemo {

   public static void main(String[] args) {

    // initializing unsorted int array
    int iArr[] = {2, 1, 9, 6, 4};

    // let us print all the elements available in list
    for (int number : iArr) {
      System.out.println("Number = " + number);
    }

    // sorting array
    Arrays.sort(iArr);

    // let us print all the elements available in list
    System.out.println("The sorted int array is:");
    for (int number : iArr) {
      System.out.println("Number = " + number);
    }
  }
}

Initial URL
http://www.tutorialspoint.com/java/util/arrays_sort_int.htm

Initial Description
An example of the Arrays.sort() function. Taken from: http://www.tutorialspoint.com/java/util/arrays_sort_int.htm

Initial Title
Java Arrays.sort() Example

Initial Tags
sort, java, array

Initial Language
Java