I want to exclude only If ColumnA = 'SA' exclude ColumnB not like '%Prev%' and ColumnB not like '%old%'. If columnA = 'BA' I want to keep them. exp:

> 
> 
> ```
> select columnA
>     from Table
>     where columnA ='SA' and ColumnB not like '%Prev%' and ColumnB not like '%old%'
> 
> ```
> 
>
['https://Stackoverflow.com/questions/67169129', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/5661085/']
It's better to implement a separate method that copies the strings with odd length:

```java
public static List<String> oddLengths(List<String> list) {
    List<String> result = new ArrayList<>();
    for (String s : list) {
        if (s.length() % 2 != 0) {
            result.add(s);
        }
    }
    return result;
}

```

Then just call this method in `main` method:

```java
List<String> list = new ArrayList<>();

list.add("yoy");
list.add("lmao");
list.add("lol");
list.add("kk");
list.add("bbb");

List<String> oddList = oddLengths(list);

System.out.println("Strings with odd length are: " + oddList);

```

Less efficient approach would be to copy the initial list and then remove all strings with *even* length using `removeIf` operation:

```java
List<String> oddList2 = new ArrayList<>(list); // no need to use clone
oddList2.removeIf(s -> s.length() % 2 == 0); // removing all strings with even length
System.out.println("Strings with odd length are: " + oddList2);

```

---

It is convenient to use Stream API with filter operation to achieve the same result:

```java
public static List<String> oddLengths(List<String> list) {
    return list.stream()
            .filter(s -> s.length() % 2 != 0)
            .collect(Collectors.toList());
}

```
modify lengths methods

```
 public static void main(String []args){
         ArrayList<String>  
        list = new ArrayList<String>();

        list.add("yoy");
        list.add("lmao");
        list.add("lol");
        list.add("kk");
        list.add("bbb");

        ArrayList<String> lengths = lengths(list);

        System.out.println(lengths.toString());
     }

     public static ArrayList<String> lengths(ArrayList<String> list) {
      ArrayList<String> lengthList = new ArrayList<String>();
      for (String s : list)
            if(s.length() % 2 != 0)
               lengthList.add(s);
        return lengthList;
     }

```