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); } } }
3 Réponses
+ 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.
+ 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".
0
how do i do that?