any idea what's wrong with this?
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("surly"); // 1
list.add("love");
list.add("lyre");
list.add("wade");
list.add("bark"); // 2
list = fix(list);
for (String s : list) {
System.out.println(s);
}
}
public static ArrayList<String> fix(ArrayList<String> list) {
ArrayList<String> res = new ArrayList<String>();
for (int i = 0; i < list.size(); i++) {
String s = list.get(i);
if (s.contains("l") && s.contains("r")) {
res.add(s);
}
else if (s.indexOf('l') >= 0 ) {
res.add(s);
res.add(s);
}
else if (s.indexOf('r') >= 0) {
;
}
}
list.clear();
for (int i = 0; i < res.size(); i++) list.add(res.get(i));
return list;
}
}