Java Sort Long Array
Chapter:
Data Structures
Last Updated:
25-09-2016 14:19:23 UTC
Program:
/* ............... START ............... */
import java.util.Arrays;
public class JavaSortLongArray {
public static void main(String[] args) {
long[] l1 = new long[] { 3, 2, 5, 4, 1 };
System.out.print("Original Array :\t ");
for (int index = 0; index < l1.length; index++)
System.out.print(" " + l1[index]);
Arrays.sort(l1);
System.out.print("\nSorted long array :\t ");
for (int index = 0; index < l1.length; index++)
System.out.print(" " + l1[index]);
long[] l2 = new long[] { 5, 2, 3, 1, 4 };
Arrays.sort(l2, 1, 4);
System.out.print("\nPartially Sorted long array :\t ");
for (int index = 0; index < l2.length; index++)
System.out.print(" " + l2[index]);
}
}
/* ............... END ............... */
Output
Original Array : 3 2 5 4 1
Sorted long array : 1 2 3 4 5
Partially Sorted long array : 5 1 2 3 4
Tags
Sort Long Array, Java, Data Structures