Advertisement
vdjalov

Untitled

Aug 10th, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. import java.io.BufferedReader;
  2. import java.io.IOException;
  3. import java.io.InputStreamReader;
  4. import java.util.ArrayList;
  5. import java.util.Arrays;
  6. import java.util.List;
  7. import java.util.stream.Stream;
  8.  
  9. public class StudentsByFirstAndLastNameZad2 {
  10.  
  11. public static void main(String[] args) throws IOException {
  12.  
  13. BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
  14. List<String> names = new ArrayList<>();
  15.  
  16.  
  17. while(true){
  18. String input[] = bf.readLine().split("[ ]+");
  19.  
  20. if(input[0].equalsIgnoreCase("end")){
  21. break;
  22. }
  23.  
  24. Stream<String> stream = Arrays.stream(input);
  25.  
  26. stream
  27. .filter(a -> a.toLowerCase().charAt(0) < input[1].toLowerCase().charAt(0))
  28. .forEach(a ->names.add(a + " " + input[1]) );
  29.  
  30. }
  31.  
  32. Stream <String> stream = names.stream();
  33. stream.forEach(a -> System.out.println(a));
  34.  
  35. bf.close();
  36. stream.close();
  37.  
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement