对象集合取某个字段的集合或拼接字符串

        List rsInfoBS = smallList();

        //"'a','b','c'"
        String collect = rsInfoBS.stream().map(r -> "'"+r.getStcd()+"'").collect(Collectors.joining(","));
        
        List collect = rsInfoBS.stream().map(r -> r.getStcd()).collect(Collectors.toList());

你可能感兴趣的:(java)