用最少的箱子 将沙包装进箱子     箱子的大小是100
如: 将80袋和15袋沙包装进一个箱子 
int nums[] ={10,23,15,40,50,60,70,80};  //沙包的数量
ArrayList bagList=new ArrayList<Integer>();
for(int i=0;i<nums.length;i++){
bagList.add(nums[i]);
}
Collections.sort(bagList);
ArrayList tank =new ArrayList();
//箱子的大小
int tanksize=100;
while (bagList<=0){

//代码从这里开始写


}
}
}tank.add(bagList);
}我自己写的  请帮忙看下 這样能实现么?
int nums[] ={10,23,15,40,50,60,70,80};  //沙包的数量
ArrayList bagList=new ArrayList<Integer>();
for(int i=0;i<nums.length;i++){
bagList.add(nums[i]);
}
Collections.sort(bagList);
ArrayList tank =new ArrayList();
//箱子的大小
int tanksize=100;
while (bagList<=0){

//代码从这里开始写

for(int j=0;j<bagList.size()-1;j++){
int box=(Integer)bagList.get(j);
if(box<tanksize){
tank.add(box);
  int y=0;
  //箱子剩下的大小
  y=tanksize -box;  
ArrayList sortList =new ArrayList<Integer>();
sortList.add(box);
Collections.sort(sortList);
//将小于装箱剩余大小的沙包数 取最大的数装入,并移除
for(int k=0;k<sortList.size()-1;k++){
int lastbox =(Integer)bagList.get(k);
tank.add(lastbox);
bagList.remove(box);
bagList.remove(lastbox);

}
}
}tank.add(bagList);
}