Java Sort long
Array
import
java.util.Arrays;
public class
SortLongArrayExample
{
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]);
System.out.print("\nSorted
long array :\t ");
for(int index=0; index
< l1.length ; index++)
System.out.print("
" + l1[index]);
ong[] 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]);
}
}
Java Sort short
Array
import
java.util.Arrays;
public class
SortShortArrayExample
{
public static void
main(String[] args)
{
short[] s1 = new
short[]{3,2,5,4,1};
System.out.print("Original
Array :\t ");
for(int index=0; index
< s1.length ; index++)
System.out.print("
" + s1[index]);
Arrays.sort(s1);
System.out.print("\nSorted
short array :\t ");
for(int index=0; index
< s1.length ; index++)
System.out.print("
" + s1[index]);
short[] s2 = new
short[]{5,2,3,1,4};
Arrays.sort(s2,1,4);
System.out.print("\nPartially
Sorted short array :\t ");
for(int index=0; index
< s2.length ; index++)
System.out.print("
" + s2[index]);
}
}
No comments:
Post a Comment