NullPointerException
Hi,
·
The attached program generates a NullPointerException at line 48, which happens to be the System.out.println statement. I have two questions:
·
a.-·· Why does it happen?
b.-·· How do I correct it?
·
The attached program generates a NullPointerException at line 48, which happens to be the System.out.println statement. I have two questions:
·
a.-·· Why does it happen?
b.-·· How do I correct it?
Comments
because it is called before main() executes.
Use the constructor of class FourDigits to pass values and initialize
the class variables.
Add a new method to the class FourDigits that prints out the values you want.
Call this new method from main().
That should resolve the issue.
But you may want to try first to define FourDigits public.
public FourDigits(...)
regards peter