Never mind, I figured out what I had to do
Printable View
Never mind, I figured out what I had to do
What errors? Post them in their entiretyQuote:
but I am getting exception errors,
The error is
Exception in thread "main" java.lang.NullPointerException
I am not really sure what is wrong, and have been trying for a very long time to get this code working, but can't seem to.
That is not the full exception - it should contain line numbers which tell you exactly where the exception is being thrown. Even then, we cannot match those line numbers up to your code given they are just small snippets (why we typically ask for an SSCCE). Find that line number and determine what is null - using System.out.println to print objects would be a first place to start to determine what is null and then backtrack to findthe cause.
This issue is with calling the method on object whose value is null.
so make sure you write a one condition (if obj!=null) before calling a method to avoid the exceptions. This is always good idea to check for validating object