package Sorting;
import javax.swing.JOptionPane;
public class Sorting2 {
public static int s[] = new int[100];
public static void main(String[] args) {
String ask = "";
for (int i = 0; i< 5;i++){
ask = JOptionPane.showInputDialog("Enter: ");
s[i] = Integer.parseInt(ask);
System.out.println(s[i]);
}
for (int x = s.length-1; x>= 0; x--) {
System.out.println(x);
}
}
}
This is my code ,i want to sort in descending the input that i made,,the problem is it does not output the descending order of the numbers i input. This is my sample input:
Enter: 2 6 8 5 7 9
Output: 9 8 7 6 5 2
But the output is:
Output: 100..............1,
because of the [100] i assigned in int [s], wil somebody help me? i really dont know how to fix it. I hope you can help me. Thank you in advance.