0
点赞
收藏
分享

微信扫一扫

java的List调用toString以后去除两端[]括号

律楷粑粑 2023-09-06 阅读 9

原始代码:

List<Integer> vids=new ArrayList<>();
            if(planList != null && planList.size() > 0){
                for (int i = 0; i < planList.size(); i++) {
                    VoicePlanListEntity voicePlanListEntity = new VoicePlanListEntity();
                    voicePlanListEntity.setVpid(voicePlanEntity.getId());
                    voicePlanListEntity.setVid(Integer.valueOf(planList.get(i).toString()));
                    voicePlanListEntity.setSort(i);
                    this.voicePlanListService.insert(voicePlanListEntity);

                   vids.add(Integer.valueOf(planList.get(i).toString()));
                }
               
                voicePlanEntity.setVid(vids.toString());
                voicePlanService.update(voicePlanEntity);
                //增加语音id
            }

去除方式:

将下面代码:

  voicePlanEntity.setVid(vids.toString());

更换为:

 voicePlanEntity.setVid(StringUtils.strip(vids.toString(),"[]"));

举报

相关推荐

0 条评论