-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram21.java
36 lines (27 loc) · 1.06 KB
/
Program21.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import java.util.Arrays;
import java.util.Collections;
/*
Program 21 : Sorting in Array with the help of inbuild functions
1. parallelSort()
2. sort()
3. sort(arr,Collections.reverseOrder()) // it will sort in decending order and we must use wrapper classes
*/
public class Program21 {
public static void main(String[] args) {
int arr[] = {213,234,145,356,267,578,489,790,100};
// Approach 1 using parallelSort() inbuild method
Arrays.parallelSort(arr);
System.out.println("Sorted Array is : "+Arrays.toString(arr));
/*
Approach 2 using sort() inbuild method
Arrays.sort(arr);
System.out.println("Sorted Array is : "+Arrays.toString(arr));
*/
/*
Approach 3 using sort()+Decending Order
Integer arr1[] = {213,234,145,356,267,578,489,790,100};
Arrays.sort(arr1,Collections.reverseOrder());
System.out.println("sorted Array in decending order : "+Arrays.toString(arr1));
*/
}
}