- April 14, 2016 at 8:14 am #9916Ajit #345
How to use Switch Clause in Apex as it is used in Java or C?
Can any one suggest me how to use switch clause in apex as it is used in java or c, need to avoid else If ladder?April 14, 2016 at 8:24 am #9925Abhinav #337
Apex does not support switch case statements.Use if else if .statements for this. However, Yes formula fields support case syntax but Apex doesn’t.April 14, 2016 at 8:33 am #9937Prafull #207
Apex doesn’t support switch clause as of now.. Salesforce will release it next year… So instead of switch case you have to use else if condition..
ThanksMarch 15, 2018 at 11:43 am #26080Phil #616
Take a look at my response on https://developer.salesforce.com/forums/?id=906F000000090xKIAQ – this is a typical object-oriented approach. Note that switch statements are really non-OO, from a purist perspective.May 31, 2018 at 10:17 am #29043Manish #319
Apex now supports Switch Statements (from Summer ’18 Release):
Please Register to reply to this topic. /