Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int removeLastItems = Integer.parseInt(command.split(" ")[1]);
- List<String> removedItems = new ArrayList<>();
- if (removeLastItems > chest.size()) {
- removeLastItems = chest.size();
- }
- for (int i = 0; i < removeLastItems; i++) {
- removedItems.add(chest.get(chest.size() - 1 - i));
- }
- chest.removeAll(removedItems);
- Collections.reverse(removedItems);
- System.out.println(removedItems.toString().replaceAll("[\\[\\]]", ""));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement