CJCoding With Joseph
15per day

Build a Generic Queue with Two Slots

Complete the MiniQueue<T> class. It has two private fields first and second that act as a two-slot queue.

- add(T item) — if first is null, store the item there. Otherwise store it in second.
- remove() — return the value of first, then shift second into first, and set second to null.

IMPORTANT: Do NOT write a main method. A hidden test will add two String values and two Integer values to separate queues, then call remove() twice on each and print the removed values in order.

Expected Output:

A
B
1
2
Topics:
GenericsClasses
Code Editor
1
Tab to indent · Ctrl+Enter to run · Ctrl+Space to expand shortcuts (sysout, psvm, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.