Remove all objects in an arraylist that exist in another arraylist Java

ArrayList<String> firstArr = new ArrayList<>();
  firstArr.add("1");
  firstArr.add("2");
  firstArr.add("3");
  
  // array/list to be removed from firstArr
  ArrayList<String> filterArr = new ArrayList<>();
  filterArr.add("1");
  filterArr.add("3");
  
  // filter now
  filterArr.removeAll(blockedArr);
  
  // Dump
  System.out.println(filterArr.toString); // output 1 and 3
  

Comments

Popular posts from this blog

Find Backlink From Google Dork

List of weapon buff materials, effects and how it can be durango wild lands

Install deb package via Termux