static void sort(int array[])
And second method allow you to sort array within range.its shown below
staic void sort(int array[],int start,int end)
In this tutorial we use loop to print array,The implementation of sort method shown below
CODING:
import java.util.*;class arraysort
{
public static void main(String args[])
{
int arr[] = {100,20,40,60,70,10};
System.out.println("Before sorting:");
for(int i=0;i<arr.length;i++)
{
System.out.println(arr[i]);
}
Arrays.sort(arr);
System.out.println("After sorting:");
for(int i=0;i<arr.length;i++)
{
System.out.println(arr[i]);
}
}
}
0 comments:
Post a Comment