public class ExamPeekableQueueImpl <E extends Comparable <E> > implements ExamPeekableQueue <E> { private Object[] arrays = new Object[this.capacity]; //holds the objects private int size=0; //current size private int capacity = 2; //default capacity private int head = -1; //location of the head of queue private int tail = -1; //location of the tail of queue //default constructor public ExamPeekableQueueImpl() { super(); } public void enqueue(E e) {if(null==e){ throw new IllegalArgumentException( "e is null "); } if(this.size()> =this.capacity||arrays.length==0){// 这里!!!!!!!! //do something } }} 下面是测试代码: public static void main(String[] args) {ExamPeekableQueueImpl <Integer> q = new ExamPeekableQueueImpl <Integer> (); q.enqueue(2); }
public class ExamPeekableQueueImpl <E extends Comparable <E> > implements ExamPeekableQueue <E> {
private Object[] arrays = new Object[this.capacity]; //holds the objects
private int size=0; //current size
private int capacity = 2; //default capacity
private int head = -1; //location of the head of queue
private int tail = -1; //location of the tail of queue
//default constructor
public ExamPeekableQueueImpl() {
super();
}
public void enqueue(E e) {if(null==e){
throw new IllegalArgumentException( "e is null ");
}
if(this.size()> =this.capacity||arrays.length==0){// 这里!!!!!!!!
//do something
}
}}
下面是测试代码:
public static void main(String[] args) {ExamPeekableQueueImpl <Integer> q = new ExamPeekableQueueImpl <Integer> ();
q.enqueue(2);
}