Advertisement
Guest User

Untitled

a guest
Dec 10th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. package com.scalefocus;
  2.  
  3. import java.lang.reflect.Array;
  4. import java.util.ArrayList;
  5. import java.util.Arrays;
  6. import java.util.Scanner;
  7.  
  8. public class Main {
  9.  
  10. public static void main(String[] args) {
  11. Scanner sc = new Scanner(System.in);
  12.  
  13. String[] words = sc.nextLine().split(" ");
  14.  
  15. //another way of converting array to stream:
  16. //Arrays.asList(words).stream()
  17. String[] resultWord = Arrays
  18. .stream(words)
  19. .filter(word -> word.length() % 2 == 0)
  20. .toArray(String[]::new);
  21.  
  22. for (String word : resultWord) {
  23. System.out.println(word);
  24. }
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement