2016.3.16_ArrayList与String()【笔记】

    if( null != temUserName ){ 
            //需要增加的用户名称
            String[] userNamesArr = temUserName.split(",");  
            //将他们放进一个ArrayList
            List<String> addnew = new ArrayList<String>();
            for(int i=0;i<userNamesArr.length;i++){
            String userName = userNamesArr[i];
            addnew.add(userName); 
            }  
             
            //取得已有的用户名称
            List<GroupUserEntity> existNamesArr = groupUserManagementServiceImpl.queryExistGroupUsersListPage(groupId); 
            //将他们放进一个ArrayList
            List<String> alreadyexist = new ArrayList<String>();
              for(int j=0;j<existNamesArr.size();j++){ 
                String existName = existNamesArr.get(j).getUserName();
                alreadyexist.add(existName); 
             } 
              //两个数组对比去重
              addnew.removeAll(alreadyexist); 
              String[] userNamesArr1 = (String[])addnew.toArray(new String[addnew.size()]); 
              
            this.groupUserManagementServiceImpl.InsertUsesToGroup(userNamesArr1, groupId);
            return Constants.SUCCESS_CODE;
        }

 

posted @ 2016-03-16 09:29  fieldcatalog  阅读(152)  评论(0编辑  收藏  举报