0

how to put this in ascending order

i need to get have the random numbers in ascending order here is my attemp import java.util.Random; import javax.swing.JOptionPane; public class espiritu_lottery{ public static void main(String[] args) { int[] lottery_numbers=new int[52]; int i; Random random=new Random(); for(i=0;i<lottery_numbers.length;i++) { lottery_numbers[i]=i+1; System.out.println(lottery_numbers[i]); } int num1; for(int y=0;y<6;y++) { num1=random.nextInt(4); JOptionPane.showMessageDialog(null,"The winning numbers are"+" "+num1+y); } } }

28th Oct 2022, 1:30 PM
Nile lon
Nile lon - avatar
3 Respostas
+ 4
You can look up "sort" or do a sort yourself by iterating through the array and comparing each number. If it's smaller, it goes towards the beginning of the array.
28th Oct 2022, 3:08 PM
Ausgrindtube
Ausgrindtube - avatar
+ 1
To look up? Open your favourite browser. Type in your favourite search engine into the address bar and hit "go". In the search field type in "sort java".
30th Nov 2022, 8:05 AM
Ausgrindtube
Ausgrindtube - avatar
0
how do i do that?
29th Nov 2022, 2:28 PM
Nile lon
Nile lon - avatar