Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.scalefocus;
- import java.lang.reflect.Array;
- import java.util.ArrayList;
- import java.util.Arrays;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- String[] words = sc.nextLine().split(" ");
- //another way of converting array to stream:
- //Arrays.asList(words).stream()
- String[] resultWord = Arrays
- .stream(words)
- .filter(word -> word.length() % 2 == 0)
- .toArray(String[]::new);
- for (String word : resultWord) {
- System.out.println(word);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement