public int top() {
if(empty()) {
return -1;//两个队列都为空,意味着当前的栈为空
}
if(!qu1.isEmpty()) {
int size = qu1.size();
int val = -1;
for (int i = 0; i < size; i++) {
val = qu1.poll();
qu2.offer(val);
}
return val;
}else {
int size = qu2.size();
int val = -1;
for (int i = 0; i < size; i++) {
val = qu2.poll();
qu1.offer(val);
}
return val;
}
}