+ Start a Discussion
Dagny FernandesDagny Fernandes 

for wrapper class Null pointer Exception: Attepting to de-reference a null object

Iam getting the null pointer exception while useing the wrapper class my other wrapper class code are working fine not able to understand what went wrrong in this code. need Help ASAP

public list<WrapperClass> wrapper_variable    {get;set;}
Account_Project_Junction__c projRec             = [SELECT Id,Name,Project__c,Project__r.Name from Account_Project_Junction__c WHERE Id = 'a00O000000KWbzsIAD'];
Escalation_Project_Junction__c EscaProjJunRec     = new Escalation_Project_Junction__c();
EscaProjJunRec.Project__c                         = projRec.Id;
EscaProjJunRec.Project_Name__c                     = projRec.Project__r.Name;
wrapper_variable.add(new WrapperClass(EscaProjJunRec));
//wrapper class
public class WrapperClass{
    public Escalation_Project_Junction__c projectEsca_wrapper{get;set;}
    
    public WrapperClass(Escalation_Project_Junction__c EPJ){
        projectEsca_wrapper = EPJ;
    }           
}


Error:
05:29:16:077 FATAL_ERROR System.NullPointerException: Attempt to de-reference a null object
this error is for the line
wrapper_variable.add(new WrapperClass(EscaProjJunRec));
Best Answer chosen by Dagny Fernandes
Parvinder SinghParvinder Singh
Seems like you are not initizing your wrapper_variable, I don't see the code where you are doing wrapper_variable= new  list<WrapperClass>();

All Answers

Parvinder SinghParvinder Singh
Seems like you are not initizing your wrapper_variable, I don't see the code where you are doing wrapper_variable= new  list<WrapperClass>();
This was selected as the best answer
Dagny FernandesDagny Fernandes
Thanks a Ton @Parvinder Singh i missed this out