В идеи работает все удаляется корректно, но тут почему то пишет, что у меня ничего не удаляется
package com.javarush.task.pro.task12.task1227;
/*
Ох уж эта жуткая корзина
*/
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class Solution {
public static List<Robot> cableContents = new ArrayList<>(Arrays.asList(new Robot("T1000"), new Robot("Amigo"),
new Robot("B1"), new Robot("Diego"), new Robot("Zed")));
public static void main(String[] args) {
//напишите тут ваш код
rescueRobots();
emptyGarbageBin();
printList(rescuedRobots);
}
//напишите тут ваш код
private static List<Robot> rescuedRobots = new ArrayList<>();
private static void rescueRobots() {
rescuedRobots.add(new Robot("Amigo"));
rescuedRobots.add(new Robot("Diego"));
for (int i = 0; i < cableContents.size(); i++) {
Robot name = cableContents.get(i);
if (name.getName().equals("Amigo") | name.getName().equals("Diego")) {
cableContents.remove(name);
}
}
}
private static void emptyGarbageBin() {
cableContents.clear();
System.out.println("Garbage cleared");
}
public static void printList(List<Robot> list) {
for (Robot o : list) {
System.out.print(o + " ");
}
System.out.println();
}
}