What is difference between != and <> usage since both the operators are used for checking inequality in if condition? Is there any performance differences or execution time difference?
They are syntactically equivalent.
However, I'd err towards always using
!= is listed as the inequality operator in the Understanding Expression Operators documentation for Apex.
!= is listed as the Not Equals operator in the SOQL Comparison Operators.
Both are listed in the Formula Operators.
Apex is a Java like language, which in turn is a C-like language. As such I'd follow the Java/C convention of using
!= for not equal to.
It is quite possible that the
<> operator is inherited from Excel's operator language specification as it is commonly seen in Validation Rules (which also support the Excel
Or(..) functions). There was a conscious attempt by SFDC to make Validation Rule formulas (as well as Formula Fields) to mimic Excel to ease user introduction to the SFDC Force.com platform.
As @DanielBallinger states,
<> is not even listed in the Apex doc although it does compile
Apparently both operators doesn't have any performance differences or execution time difference. As they haven't listed it explicitly in documentation.
Source - Salesforce Docs