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 }
1// an array of ints
2int[] arr = {1, 2, 3, 4, 5, 6};
3
4// an array of reverse sorted ints
5int[] arrDesc = Arrays.stream(arr).boxed()
6 .sorted(Collections.reverseOrder())
7 .mapToInt(Integer::intValue)
8 .toArray();
9
10System.out.println(Arrays.toString(arrDesc)); // outputs [6, 5, 4, 3, 2, 1]