Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- List<String> fruits = Arrays.asList("Orange", "Apple", "Plum", "Medlar", "Durian", "Strawberry");
- List<String> result = new ArrayList<>();
- for (String fruit : fruits) {
- if (fruit.endsWith("e")) {
- result.add(fruit);
- } else {
- break;
- }
- }
- System.out.println(result);
Add Comment
Please, Sign In to add comment