Guest User

Untitled

a guest
Apr 26th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. import java.util.ArrayList;
  2. import java.util.List;
  3. import java.util.stream.Collectors;
  4.  
  5. public class Test {
  6.  
  7. private String id;
  8.  
  9. public Test(String id) {
  10. this.id = id;
  11. }
  12.  
  13. public static void main (String[] args) {
  14.  
  15. List<Test> myList = new ArrayList<>();
  16. myList.add(new Test("foo"));
  17. myList.add(new Test("bar"));
  18. myList.add(new Test("foobar"));
  19.  
  20. String ids = myList.stream().map(n -> n.id).collect(Collectors.joining(" "));
  21.  
  22. System.err.println("'" + ids + "'");
  23.  
  24. }
  25. }
Add Comment
Please, Sign In to add comment