Guest User

Untitled

a guest
Jan 16th, 2019
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. List<String> phones = new ArrayList<String>();
  2. Collections.addAll(phones, "iPhone X", "Nokia 9", "Huawei Nexus 6P",
  3. "Samsung Galaxy S8", "LG G6", "Xiaomi MI6", "Sony Xperia Z5",
  4. "ASUS Zenfone 3", "Meizu Pro 6", "Heizu Pro 6",
  5. "Pixel 2");
  6.  
  7. phones.stream().sorted(Comparator.comparingInt(String::length).reversed()).forEach(System.out::println);
  8.  
  9. Samsung Galaxy S8
  10. Huawei Nexus 6P
  11. Sony Xperia Z5
  12. ASUS Zenfone 3
  13. Meizu Pro 6
  14. Heizu Pro 6
  15. Xiaomi MI6
  16. iPhone X
  17. Nokia 9
  18. Pixel 2
  19. LG G6
  20.  
  21. Sony Xperia Z5
  22. ASUS Zenfone 3
  23.  
  24. Meizu Pro 6
  25. Heizu Pro 6
Add Comment
Please, Sign In to add comment