Java
このプログラムを実行した結果 [10,20,30,40,50](5) dequeue 10 [20,30,40,50](4) [20,30,40,50,60](5) dequeu 20 [30,40,50,60](4) dequeue 30 dequeue 40 dequeue 50 dequeue 60 [70](1) という感じに表示させたいのですが、これを表示させるためにIntQueue.javaをどのように改善したらよいですか?長くなりますが回答してもらえると助かります!! package exer3.queue.tester; import exer3.queue.*; public class TesterQ03 { public static void main(String[] args) { Queue q1 = new IntQueue(5); q1.enqueue(10); q1.enqueue(20); q1.enqueue(30); q1.enqueue(40); q1.enqueue(50); System.out.println(q1); System.out.printf("dequeue %d¥n", q1.dequeue()); System.out.println(q1); q1.enqueue(60); System.out.println(q1); System.out.printf("dequeue %d¥n", q1.dequeue()); q1.enqueue(70); System.out.println(q1); System.out.printf("dequeue %d¥n", q1.dequeue()); System.out.printf("dequeue %d¥n", q1.dequeue()); System.out.printf("dequeue %d¥n", q1.dequeue()); System.out.printf("dequeue %d¥n", q1.dequeue()); System.out.println(q1); } } package exer3.queue; import java.util.StringJoiner; public class IntQueue implements Queue<Integer> { private Integer[] data; private int in, out, size; public IntQueue() { this(8); } public IntQueue(int max) { data = new Integer[max]; in = 0; out = 0; size = 0; } public boolean enqueue(Integer v) { data[in] = v; in += 1; return true; } public Integer dequeue() { Integer ans = null; ans = data[out]; out += 1; return ans; } public boolean isEmpty() { return (0 == size); } public void clear() { size = 0; in = 0; out = 0; } public int size() { return size; } public String toString() { StringJoiner j = new StringJoiner(","); for (int p = 0, s = 0; s < data.length; s++) { j.add(data[p].toString()); p += 1; } return "[" + j.toString() + "](" + size + ")"; } } package exer3.queue; public interface Queue <V> { public boolean enqueue(V v); public V dequeue(); public boolean isEmpty(); public void clear(); public int size(); }