Write a program to sort an int array in descending order?
Reverse sort algorithm:
package Array;
/**
*
* @author stratos
*/
public class ArraySorting {
public static void main(String[] args) {
int a[] = {5, 6, 1, 4, 3};
int temp;
for (int i = 0; i <= a.length - 1; i++) {
//System.out.println(a[i]);
for (int j = 0; j < a.length - 1; j++) {
if (a[j] < a[j + 1]) {
temp = a[j];
a[j] = a[j + 1];
a[j + 1] = temp;
}
}
}
for (int k = 0; k <= a.length - 1; k++) {
System.out.println(a[k]);
}
}
}
6 5 4 3 1




post a comment