Exception in thread "main" java.lang.NullPointerException -


this question has answer here:

getting exception while running following program

exception in thread "main" java.lang.nullpointerexception     @ pojo.bill.main(bill.java:20) java result: 1 

bill.java

public class bill {     public static void main(string s[]){         bill b=new bill();         b.getbilldetails().setbillno(444);// line 20         system.out.println("bill no "+ b.getbilldetails().getbillno());     }      private billaction billdetails;      public billaction getbilldetails() {         return billdetails;     }      public void setbilldetails(billaction billdetails) {         this.billdetails = billdetails;     } 

in billaction there getter , setter of billno how resolve this.

billdetails not initialized. , calling method on it. whenever calling method on "null" null pointer exception

so this, private billaction billdetails= new billaction();


Comments

Popular posts from this blog

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -