Advertisement
jtentor

DemoQueue1 - DemoQueue1.java

May 17th, 2020
541
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.88 KB | None | 0 0
  1. import java.util.Random;
  2.  
  3. public class DemoQueue1 {
  4.     public static void main(String[] args) {
  5.         System.out.print("Demo Queue - versión genérica\n");
  6.  
  7.         Queue<Integer> queue1 = new Queue<Integer>(10);
  8.         Queue<Integer> queue2 = new Queue<Integer>(10);
  9.  
  10.         Random random = new Random();
  11.  
  12.         int number;
  13.         int character;
  14.         System.out.print("Enqueuing...\n");
  15.         for (int c = 0; c < 10; ++c) {
  16.             queue1.add(number = random.nextInt(10001) - 5000);
  17.             queue2.add(character = random.nextInt(25) + 65);
  18.             System.out.printf("%d %c ", number, character);
  19.         }
  20.         System.out.print("\n");
  21.  
  22.         System.out.print("Dequeuing...\n");
  23.         while(queue1.size() > 0) {
  24.             System.out.printf("%d %c ", queue1.remove(), queue2.remove());
  25.         }
  26.         System.out.print("\n");
  27.  
  28.     }
  29.  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement