数组转list,list转数组、数组扩容、数组复制方法

        String roleId = "1,2,3";
        String[] roleIds = roleId.split(",");
        //数组转List
        List roleList = Arrays.asList(roleIds);

        //查询父节点的角色Id
        List<String> parentIds =  uaRoleDao.queryParentFunId(paramMap);
        //将集合转换成数组
        String[] parentArray = (String[]) parentIds.toArray(new String[parentIds.size()]);
        if(parentIds!=null&&parentIds.size()>0){
            //扩容
            functions = Arrays.copyOf(functions, functions.length+parentArray.length);
            //拷贝数组到functions
            System.arraycopy(parentArray, 0, functions, functions.length-parentArray.length, parentArray.length);
        }

你可能感兴趣的:(java)