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
  

0 Response to "Remove all objects in an arraylist that exist in another arraylist Java"

Post a comment

Bila Ada posting yang kurang, atau error atau yang lainnya, silahkan tinggalkan komentar agar artikel/post di perbaiki.
Jangan Lupa Cek Box "Notify Me" agar tahu komentar kamu dibalas oleh saya.

If there are any posts that are missing, or error or anything else, please leave a comment for the article / post to be fixed.
Do not Forget Check Box "Notify Me" to know our comments replied by me.

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel