1

When I'm using % symbol it is showing the below error message:

Found punctuation symbol or operator '%' that isn't valid in Apex.

8

In most languages that use it, it represents the modulus operation.

In APEX, you use Math.Mod()

if (Math.Mod(x, 2) == 0) {
    system.debug(x + ' is even');
}

APEX Expression Operators Reference shows that there is no definition of a % operator.

  • thank u it is working. but i want to know more information about these symbols is there any examples? – user57471 Jun 11 '18 at 17:03
  • All of the information you'll need is in the links I posted. The first one shows the math class and everything that it can do and the second shows all of the operators that are supported in salesforce alongside descriptions for them. – gNerb Jun 11 '18 at 17:06
  • 1
    @user57471 Don't forget to accept the answer by clicking the check box. This is how you show the community that this answer worked for you and others with the same question will know what the right answer is. – gNerb Jun 11 '18 at 17:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.