Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- import java.util.List;
- import java.util.stream.Collectors;
- public class Test {
- private String id;
- public Test(String id) {
- this.id = id;
- }
- public static void main (String[] args) {
- List<Test> myList = new ArrayList<>();
- myList.add(new Test("foo"));
- myList.add(new Test("bar"));
- myList.add(new Test("foobar"));
- String ids = myList.stream().map(n -> n.id).collect(Collectors.joining(" "));
- System.err.println("'" + ids + "'");
- }
- }
Add Comment
Please, Sign In to add comment