Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
svetlanasieber authored May 28, 2024
1 parent f1698e1 commit 2290db8
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import java.util.Arrays;
import java.util.Scanner;
import java.util.function.Predicate;

public class P06_PredicateForNames {

public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);

int n = Integer.parseInt(scanner.nextLine());

Predicate<String> lengthFilter = str -> str.length() <= n;

Arrays.stream(scanner.nextLine().split("\\s+"))
.filter(lengthFilter)
.forEach(System.out::println);

}
}

0 comments on commit 2290db8

Please sign in to comment.