import java.util.Random;
public class DemoQueue1 {
public static void main(String[] args) {
System.out.print("Demo Queue - versión genérica\n");
Queue<Integer> queue1 = new Queue<Integer>(10);
Queue<Integer> queue2 = new Queue<Integer>(10);
Random random = new Random();
int number;
int character;
System.out.print("Enqueuing...\n");
for (int c = 0; c < 10; ++c) {
queue1.add(number = random.nextInt(10001) - 5000);
queue2.add(character = random.nextInt(25) + 65);
System.out.printf("%d %c ", number, character);
}
System.out.print("\n");
System.out.print("Dequeuing...\n");
while(queue1.size() > 0) {
System.out.printf("%d %c ", queue1.remove(), queue2.remove());
}
System.out.print("\n");
}
}
Comments