jtentor

DemoList4.java [lista ordenada]

Oct 22nd, 2016
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.52 KB | None | 0 0
  1.  
  2. import java.util.Random;
  3.  
  4. public class DemoList4 {
  5.  
  6.     public static void main(String[] args) {
  7.         System.out.println("Demo de lista ordenada");
  8.  
  9.         Random random = new Random();
  10.  
  11.         List<Integer> lista1 = new List<Integer>();
  12.        
  13.         int num;
  14.         System.out.printf("\nNumeros: ");
  15.         for (int i = 0; i < 20; ++i) {
  16.             num = random.nextInt(1000);
  17.             System.out.printf("%d ", num);
  18.             lista1.AddInOrder(num);
  19.         }
  20.        
  21.         System.out.printf("\n\nLista1: ");
  22.         for (int n : lista1) {
  23.             System.out.printf("%d ", n);
  24.         }
  25.  
  26.     }
  27.  
  28. }
Add Comment
Please, Sign In to add comment