deyanmalinov

02. Upper Strings - Single Line

Apr 21st, 2020
407
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package DPM;
  2. import java.util.Arrays;
  3. import java.util.List;
  4. import java.util.Scanner;
  5. import java.util.stream.Collectors;
  6.  
  7. public class Main {
  8.     public static void main(String[] args) {
  9.         Scanner scan = new Scanner(System.in);
  10.  
  11.         List<String> names = Arrays.stream(scan.nextLine()
  12.                 .split(" "))
  13.                 .collect(Collectors.toList());
  14.  
  15.         names.stream()
  16.                 .map(name -> name.toUpperCase())
  17.                 .forEach(name -> System.out.print(name + " "));
  18. //////////////////////////////////////////////////////////////
  19. Arrays.stream(scan.nextLine()
  20.                 .split(" "))
  21.                 .collect(Collectors.toList()).stream()
  22.                 .map(name -> name.toUpperCase())
  23.                 .forEach(name -> System.out.print(name + " "));
  24. /////////////////////////////////////////////////////////////
  25.  
  26.     }
  27. }
RAW Paste Data