Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package DPM;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.Scanner;
- import java.util.function.Predicate;
- public class Main {
- public static void main(String[] args){
- Scanner scan = new Scanner(System.in);
- String[] sentense = scan.nextLine().split("\\s+");
- Predicate<String> toUpper = word -> {
- return word.charAt(0) == word.toUpperCase().charAt(0);
- };
- List<String> words = new ArrayList<>();
- for (String str : sentense) {
- if (toUpper.test(str)){
- words.add(str);
- }
- }
- System.out.println(words.size());
- words.forEach(System.out::println);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment