Activity Forums Salesforce® Discussions How to check if list contains the specified element in Salesforce ?

  • How to check if list contains the specified element in Salesforce ?

  • Kirandeep

    Member
    October 27, 2020 at 3:22 pm

    How to check if list contains the specified element in Salesforce ?

  • Anuj

    Member
    October 27, 2020 at 3:28 pm
    1. Define a new Set. Set<String> mySet = new Set<String>();
    2. Use the Set. addAll() method to add all of the List elements to the set. mySet. addAll(myList); .
    3. Use the Set. contains() method to check the Set for the element you're looking for.
Viewing 1 - 2 of 2 posts

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos