Activity Forums Salesforce® Discussions How to compare two strings in Apex in Salesforce?

  • How to compare two strings in Apex in Salesforce?

    Posted by Anjali on August 5, 2020 at 10:00 AM

    How to compare two strings in Apex in Salesforce?

    Ayush replied 6 years ago 3 Members · 2 Replies
  • 2 Replies
  • MOHIT

    Member
    August 5, 2020 at 10:54 AM

    String comparisonequals() method should be used for content comparison instead. Unlike Java, the == operator in Apex compares object value equality and not reference equality. The exception is user-defined types. Thus, for sObjects and sObjects arrays comparison the == operator should be used.

  • [adinserter block='9']
  • Ayush

    Member
    August 5, 2020 at 11:27 AM

    the comparison of Strings using the == operator and using the Object.equals() method.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos