Alaax89

java

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