81,092
社区成员
发帖
与我相关
我的任务
分享
List<ShopCategory> result = new ArrayList<ShopCategory>();
public List<ShopCategory> getCategory(List<ShopCategory> list, int pid, int level)
{
for(ShopCategory categorylist : list)
{
if(categorylist.getPid()==pid)
{
ShopCategory cate = new ShopCategory();
cate.setPid(categorylist.getPid());
cate.setShopcategoryid(categorylist.getShopcategoryid());
cate.setShopcategory(categorylist.getShopcategory());
result.add(cate);
getCategory(list,categorylist.getShopcategoryid(), level+1);
}
}
return result;
}
看看这个代码试试吧。。。。