Exception in thread "main" java.lang.NullPointerException -
this question has answer here:
- what nullpointerexception, , how fix it? 12 answers
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
Post a Comment