Advertisement
jtentor

DemoList5 - DemoList5.java

Jun 8th, 2020
1,260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.63 KB | None | 0 0
  1. // Created by Julio Tentor <jtentor@fi.unju.edu.ar>
  2. //
  3. import java.util.Random;
  4.  
  5. public class DemoList5 {
  6.     public static void main(String[] args) {
  7.         System.out.println("Demo de lista enlazada doble con iterador y comparable");
  8.  
  9.         Random random = new Random();
  10.  
  11.         DoubleLinkedListIteratorComparable<Integer> lista1 = new DoubleLinkedListIteratorComparable<Integer>();
  12.  
  13.         int num;
  14.         System.out.print("Numeros: ");
  15.         for (int i = 0; i < 6; ++i) {
  16.             num = random.nextInt(101);
  17.             System.out.printf("%d ", num);
  18.             lista1.addInOrder(num);
  19.         }
  20.         System.out.println();
  21.  
  22.  
  23.         System.out.print("Lista1.: ");
  24.         for (Integer element: lista1) {
  25.             System.out.printf("%d ", element);
  26.         }
  27.         System.out.println();
  28.  
  29.         //PersonDemo();
  30.     }
  31.  
  32.     private static void PersonDemo() {
  33.         Person[] peopleArray = new Person[3];
  34.         peopleArray[0] = new Person("Lopez", "Jorge");
  35.         peopleArray[1] = new Person("Perez", "Juan");
  36.         peopleArray[2] = new Person("Armata", "Jose");
  37.  
  38.         System.out.println("Personas en el arreglo: ");
  39.         for (Person person : peopleArray) {
  40.             System.out.println(person);
  41.         }
  42.  
  43.         DoubleLinkedListIteratorComparable<Person> peopleList = new DoubleLinkedListIteratorComparable<Person>();
  44.         for( Person person: peopleArray) {
  45.             peopleList.addInOrder(person);
  46.         }
  47.         System.out.println("Personas en la lista ordenada: ");
  48.         for (Person person : peopleList) {
  49.             System.out.println(person);
  50.         }
  51.     }
  52.  
  53.  
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement