The strong point of this Java code is that, we make use of TreeSet Collection for sorting the array in reverse order. The Java code is provided below:-
import java.util.TreeSet;
public class SortingDescending {
@SuppressWarnings("unchecked")
public static void main(String[] args) {
int[] num = {3,5,9,2,1,0,45,23,67,93};
TreeSet ts = new TreeSet();
for(int i = 0; i < num.length; i++)
{
ts.add(num[i]);
}
System.out.println("The numbers of the array in descrending order are: "+ts.descendingSet());
}
}
I hope the Java Code provided was helpful to you all. For more info on Java, keep buzzing Java Code Online.
0 komentar:
Posting Komentar