Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- import java.util.Arrays;
- import java.util.Collections;
- import java.util.Random;
- public class CollectionSortEx1 {
- private static ArrayList<Integer> al = new ArrayList<Integer>();
- public static void main(String[] args) {
- Random random = new Random();
- for(int i = 0; i < 100; i++) {
- al.add(random.nextInt(100));
- }
- printAl();
- Collections.sort(al);
- printAl();
- }
- private static void printAl() {
- for(int i : al) {
- System.out.print( i + ", ");
- }
- System.out.println();
- }
- }
Add Comment
Please, Sign In to add comment