Guest User

Untitled

a guest
Oct 23rd, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. import java.util.ArrayList;
  2. import java.util.Arrays;
  3. import java.util.Collections;
  4. import java.util.Random;
  5.  
  6. public class CollectionSortEx1 {
  7. private static ArrayList<Integer> al = new ArrayList<Integer>();
  8.  
  9. public static void main(String[] args) {
  10.  
  11. Random random = new Random();
  12.  
  13. for(int i = 0; i < 100; i++) {
  14. al.add(random.nextInt(100));
  15. }
  16.  
  17. printAl();
  18. Collections.sort(al);
  19. printAl();
  20. }
  21.  
  22. private static void printAl() {
  23. for(int i : al) {
  24. System.out.print( i + ", ");
  25. }
  26. System.out.println();
  27. }
  28. }
Add Comment
Please, Sign In to add comment