Java中的ArrayBlockingQueue add()方法
要将元素添加到ArrayBlockingQueue类,请使用add()方法。
语法如下
boolean add(E ele)
此处,ele是要添加到队列中的元素。
要使用ArrayBlockingQueue类,您需要导入以下包
import java.util.concurrent.ArrayBlockingQueue;
以下是在JavaArrayBlockingQueue类中添加元素的示例
示例
import java.util.concurrent.ArrayBlockingQueue;
public class Demo {
public static void main(String[] args) {
ArrayBlockingQueue<Integer> q = new ArrayBlockingQueue<Integer>(7);
q.add(100); q.add(250); q.add(300); q.add(450); q.add(550); q.add(600); q.add(700);
System.out.println("ArrayBlockingQueue = " + q);
}
}输出结果
ArrayBlockingQueue = [100, 250, 300, 450, 550, 600, 700]
热门推荐
10 儿子立冬祝福语简短独特
11 对当兵的祝福语简短
12 侄儿高考试祝福语简短
13 伴郎红包祝福语朋友简短
14 媳妇生日简短祝福语朋友
15 公司年会祝福语简短最好
16 元旦感恩祝福语简短大全
17 红包祝福语简短10字
18 周六早晨祝福语简短