• Amit Chaudhary 7
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies
Same code works in anonymous window but in test class it shows list index out of bound error .

@istest

public class setMethod{
 
    public static testmethod void main(){
        
        List<student__c> sts = new List<student__c>();
  sts =[select name from student__c ] ;
        
        
           string temp = sts.get(2).name ;
     
        system.debug(temp);
    }    
}