Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- List<String> phones = new ArrayList<String>();
- Collections.addAll(phones, "iPhone X", "Nokia 9", "Huawei Nexus 6P",
- "Samsung Galaxy S8", "LG G6", "Xiaomi MI6", "Sony Xperia Z5",
- "ASUS Zenfone 3", "Meizu Pro 6", "Heizu Pro 6",
- "Pixel 2");
- phones.stream().sorted(Comparator.comparingInt(String::length).reversed()).forEach(System.out::println);
- Samsung Galaxy S8
- Huawei Nexus 6P
- Sony Xperia Z5
- ASUS Zenfone 3
- Meizu Pro 6
- Heizu Pro 6
- Xiaomi MI6
- iPhone X
- Nokia 9
- Pixel 2
- LG G6
- Sony Xperia Z5
- ASUS Zenfone 3
- Meizu Pro 6
- Heizu Pro 6
Add Comment
Please, Sign In to add comment