• Syed F Raza 10
  • NEWBIE
  • 0 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies
Hi All,

The following tag is executing as per requirement:
 
List<integer> list1= new List<integer>();
list1.add(10);
list1.add(20);
list1.add(30);
list1.add(40);
system.debug('Value of List after increase is '+list1);

However if I use the list.add(index,element) method to add elements I am receivng error System.ListException: List index out of bounds: 0

The code I am having error with is
 
List<integer> list1= new List<integer>();
list1.add(0,10);
list1.add(1,20);
list1.add(2,30);
list1.add(3,40);
system.debug('Value of List after increase is '+list1);
Please advise.

Thanks!!
 
Hi All,

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.
 
Hi All,

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.