The following code to try to catch a NullPointerException
via logging is not working. Can someone please look at this and guide me.
try {
if (results1 != 00.00) {
throw new Exception("Data must be added");
}
}
catch (Exception e) {
log.error("You have an error", e);
}
The user must enter a value for results1 as it is used for a calculation. Results1 is a double as it is a percentage, I am willing to change it to an int if thats what it takes to make it work. I also want to check through the try and catch technique if a user accidently added a % sign. I want my logger to catche the NumberFormatException for testing purposes.
UPDATE: Ok thanks for the feedback ( I somehow overlooked that). It still doesn't work. I think this might be the problem:
(results1 != 00.00)
Is this the best way to check if the input is empty for a double. Also How can i check if a string is added?