1Here’s the java program to sort an array using Arrays.sort() method.
2
3import java.util.Arrays;
4public class JavaArraySortMethod
5{
6 public static void main(String[] args)
7 {
8 String[] strGiven = {"Great Barrier Reef", "Paris", "borabora", "Florence","tokyo", "Cusco"};
9 Arrays.sort(strGiven);
10 System.out.println("Output(case sensitive) : " + Arrays.toString(strGiven));
11 }
12}
1int countOfArray = 5;
2int num [] = new int[counfOfArray];
3
4int num[] = [8 , 5 , 9 , 3 , 4];
5
6for (int i = 0; i < countOfArray; i++)
7 {
8 for (int j = i + 1; j < countOfArray; j++) {
9 if (num[i] > num[j])
10 {
11 temp = num[i];
12 num[i] = num[j];
13 num[j] = temp;
14 }
15 }
16 }
1import java.util.Arrays;
2public class JavaArraySortMethod
3{
4 public static void main(String[] args)
5 {
6 String[] strGiven = {"Great Barrier Reef", "Paris", "borabora","tokyo", "Cusco"};
7 Arrays.sort(strGiven);
8 System.out.println("Output(case sensitive) : " + Arrays.toString(strGiven));
9 }
10}