I have two String
lists.
List-1 Ex.: "ftzat955","zat75" "a875rt955", "rRat955", "duozf", "ulw7trRT"
List-2 Ex.: "rt", "zf"
Now I want to loop the first List
and delete all the String
that contain "rt"
and "zf"
from List-2.
I am not searching against a complete string instead I'm only searching for a string-pair in whole strings.
I didn't find any Utils
that I can use to solve this problem.
Can somebody help me with this?
Thank you for helps.
List<String> resultList = new ArrayList<String>();
for (String l1 : list1)
{
boolean stay = true;
for (String l2 : list2)
if (l1.contains(l1))
stay = false;
if (stay)
resultList.add(l1);
}
public ArrayList<String> filterList(ArrayList<String> mainList, ArrayList<String> comparableList){
ArrayList<String> filteredList=new ArrayList<String>();
for(String s: comparableList){
for (String s2:mainList){
if(s2.contains(s))filteredList.add(s2);
}
}
return filteredList;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.