Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayDeque;
- import java.util.LinkedList;
- import java.util.Queue;
- import java.util.Random;
- public class DemoQueue2 {
- public static void main(String[] args) {
- System.out.print("Demo Queue - versión librería estándar\n");
- Queue<Integer> queue1 = new ArrayDeque<Integer>(10);
- Queue<Integer> queue2 = new LinkedList<Integer>();
- Random random = new Random();
- int number;
- int character;
- System.out.println("Enqueuing...");
- 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.println("Dequeuing...");
- while(queue1.size() > 0) {
- System.out.printf("%d %c ", queue1.remove(), queue2.remove());
- }
- System.out.print("\n");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement