对于错误的参数,可以通过异常来提示用户,达到一种强制性错误改正的作用。
public LinkedBlockingQueue(int capacity) { if (capacity <= 0) throw new IllegalArgumentException();//参数不合法 this.capacity = capacity; last = head = new Node<E>(null); }
对于错误的参数,可以通过异常来提示用户,达到一种强制性错误改正的作用。
public LinkedBlockingQueue(int capacity) { if (capacity <= 0) throw new IllegalArgumentException();//参数不合法 this.capacity = capacity; last = head = new Node<E>(null); }