JAVA_collection_集合相关知识点(二、获取集合对象中某个属性的集合——CollectionUtils.collect()方法)

        List userList = new ArrayList();
        List userNameList = (List) CollectionUtils.collect(userList, new Transformer() {
            @Override
            public Object transform(Object o) {
                User user = (User) o;
                return user.getName();
            }
        });

 

你可能感兴趣的:(j2ee)