ArrayList a;//你已经有的a;
ArrayList b;//你已经有的b;
ArrayList c= new ArrayList()
比较a.size()大还是b.size()大,大的=e,小的=q
for(int i=0i<ei++){
if(i<q){
c.add(a.get(i))
c.add(b.get(i))
}
if(i>=q){
c.add(b.get(i))
}
}
写的这样也差不多了吧
队列为空的情况下 在首部添加新节点的时候,其实firstNode和lastNode相同都是newNode,但是无论队列是否为空 方法的最后都会设置firstNode=newNode, 所以为空的时候会设置lastNode=newNode; 在尾部添加新节点的道理也是这样;