what is wrong?2nd and 3rd conditions are not satisifed
package com.codegym.task.task07.task0716;
import java.util.ArrayList;
/*
R or L
*/
public class Solution {
public static void main(String[] args) throws Exception {
ArrayList<String> list = new ArrayList<String>();
list.add("rose"); // 0
list.add("red"); // 1
list.add("love"); // 2
list = fix(list);
for (String s : list) {
System.out.println(s);
}
}
public static ArrayList<String> fix(ArrayList<String> list) {
int j=0;
ArrayList<String> list2 = new ArrayList<String>();
list2.addAll(list);
for(int i=0;i<3;i++ ){
if(!(list.get(i).contains("l"))&& (list.get(i).contains("r"))){
list2.remove(list.get(i));
}
else if((list2.get(i).contains("l"))&& !(list.get(i).contains("r"))){
list2.add(list.get(i));
}
else if((list.get(i).contains("l"))&& (list.get(i).contains("r"))){
continue;
}
else if(!(list.get(i).contains("l"))&& !(list.get(i).contains("r"))){
continue;
}
}
return list2;
}
}