You need to sign in to do that
Don't have an account?

IF ELSE Condition in List
Hi All,
I am having trouble with the below code:
The showAccountsBasedOnRating() method is executing as per expectations.
The showIndustryOfAccounts() method is executing with upto "IF" command but the ELSE commoand is not executing.
Any idea what could be causing this.
Thanks.
I am having trouble with the below code:
Public Class SOQLTry{ public static void showAccountsBasedOnRating(String AccountRating){ List<Account> List2 = [SELECT Name, Rating FROM Account WHERE Rating IN (:AccountRating)]; For(Account AAR : List2) { system.debug('Name of Account with Rating ' +AAR.Rating+' is '+AAR.Name ); } } public static void showIndustryOfAccounts(String AccountIndustry){ List<Account> List3 = [SELECT Name, Industry FROM Account WHERE Industry = :AccountIndustry]; for(Account AAI : List3) { IF(List3.isEmpty()==False) { system.debug(AAI.Name+' belongs to the '+AAI.Industry+' Industry'); } ELSE { system.debug('There is no account related to '); } } } }
The showAccountsBasedOnRating() method is executing as per expectations.
The showIndustryOfAccounts() method is executing with upto "IF" command but the ELSE commoand is not executing.
Any idea what could be causing this.
Thanks.
Thanks for your response.
You have to write like this:
Thanks,
Maharajan.C