2
I need to organize the values that the array receives randomly and leave them in descending order, but honestly I don’t know how to do it, there’s my code, I couldn’t organize.
package gerarOrganizar;
import java.util.Random;
public class GerarOrganizar {
public static void main(String[] args) {
int i=0;
int[] array = new int[10];
Random gerador=new Random();
int[] arrayF= new int[10];
int j = 0;
for(i=0;i<10;i++){
array[i]=gerador.nextInt(25);
if(array[i]==0)
i--;
}//for
while(j<10){//meu problema começa daqui em diante
for(j=0;j<10;j++){
for(i=0;i<10;i++){
if(comp<array[i]){
comp=array[i];
arrayF[j]=array[i];
}//if
}//segundo for
}//primeiro for
System.out.println(arrayF[j]);
}//while
}//main
}//class
You need to implement the sorting algorithm yourself, or you can use a ready-made sorting method available in the JDK?
– Piovezan