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

Getting Null Pointer Exception
I am trying to add months to a date field and add that value to the List<Date>. I am getting null pointer exception
Apex Code
I am getting Null Pointer exceptbill.add(newBill). I used system debug statement shows the correct value.
Cant understand how to fix this.
Any help would be aapreciated!
Apex Code
public class stndReduceExcel { public Contingency__c stndReduce{get;set;} public List<Date> bill{get;set;} ApexPages.StandardController controller; public stndReduceExcel(ApexPages.StandardController con){ controller = con; stndReduce = [Select name, Account__c, BILLING_BEGINS_DATE__c, Num_to_Bill__c from Contingency__c where id = :System.currentPagereference().getParameters().get('id')]; Date newbill = stndReduce.BILLING_BEGINS_DATE__c; for(Integer i = 1; i <= stndReduce.Num_to_Bill__c ; i++){ newBill = newBill.addMonths(i); system.debug(newBill); bill.add(newBill); } } }
I am getting Null Pointer exceptbill.add(newBill). I used system debug statement shows the correct value.
Cant understand how to fix this.
Any help would be aapreciated!

You need the following line at the beginning of your stndReduceExcel method in order to instantiate the bill List.