It works on Intellij IDEA
public class Main {


    public static void main(String[] args) throws Exception {
        ArrayList<String> list = new ArrayList<String>();
        list.add("rose");
        list.add("love");
        list.add("lyre");
        list.add("adamos");
        list.add("phill");
        list.add("Horaz");
        list.add("Berengar");
        list.add("Beryll");
        list = fix(list);

        for (String s : list) {
            System.out.println(s);
        }
    }
    public static ArrayList<String> fix(ArrayList<String> list) {

        ArrayList<String> list2 = new ArrayList<>(); // create 2nd empty list

        for (int i=0; i < list.size(); i++) {
            if (list.get(i).contains("l") && list.get(i).contains("r") == true) {
                list2.add(list.get(i)); // add 1 x element containing "l" and "r" to 2nd list
            }
            else if (list.get(i).contains("l") == true) {
                list2.add(list.get(i)); // add 2 x element containg "l" to 2nd list
                list2.add(list.get(i));
            } // do not add any elements containing "r" or not containing "r" or/and "l"
          else  if (list.get(i).contains("r") == true) {
                list2.remove(list.get(i)); // add 1 x element containing "l" and "r" to 2nd list
            }
        }

        return list2; // return 2nd list
    }
}
That's compile but second and last statement aren't work.. but they work in Intellij IDEA