function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Nehru komuNehru komu 

i want to remove value from list if exists in another list like List A having 1,2,3 and List B Having 1 as value and i want to remove value 1 in List A and finnaly List A ha 2,3

Best Answer chosen by Nehru komu
Jolly_BirdiJolly_Birdi
Hello @Nehru

Please try this below Code:

Change aList and bList with your list values.
List<Integer> aList = new List<Integer>(); // List 1
List<Integer> bList = new List<Integer>(); // List 2

for(Integer i : bList){
    Integer indexOfI = aList.indexOf(i);
    if(indexOfI > -1)
    	aList.remove(indexOfI);
}

Please mark this as best answer, If you find it positive.

Thanks,
Jolly Birdi