Integer number =null; //越界问题
if(queueNumber.size()>0);{
number = queueNumber.remove(0);//返回的对象,如果取到NULL,空指针异常
}
return number;
----------------------------------------------------------------------------------
if(queueNumber.size()>0){
return (Integer)queueNumber.remove(0);
}else{
return null;*/
----------------------------------------------------------------------------------
上下两种防止越界的方式不一样么?为什么我执行出来结果不一样,上面的还是会有报错Exception in thread "pool-3-thread-1" Exception in thread "pool-2-thread-1" java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
|
|