0

This code snippet:

public class NumberFormatException extends IllegalArgumentException {

public NumberFormatException (String test) {
super (test);
}

static NumberFormatException forInputString(String test) {
    return new NumberFormatException("Caused By: \"" + test + "\"");
}
}

throws NullPointerException:

java.lang.NullPointerException

at java.lang.NumberFormatException.forInputString(NumberFormatException.java)

I'm unable to ascertain what value of 'test' can be the root cause of a NullPointerException since in the concatenation, null is printed on the screen if the value of a String is null.

KLCoder
  • 89
  • 2
  • 3
  • 11
  • 2
    I am somewhat certain that this line is not the source of the `NullPointerException` (especially because you say it prints `"Caused By: null"`. Can you please include the exact Error message as well as the relevant code? – Turing85 Apr 19 '17 at 07:42
  • @Turing85: In the stack trace, I'm not getting : "Caused By: null" – KLCoder Apr 19 '17 at 07:44
  • @KLCoder it´s most likely the surrounding class that´s `null`, or whatever you call there, but this pretty much can´t produce a `NPE` – SomeJavaGuy Apr 19 '17 at 07:45
  • @GhostCat : Help/Guide where the above issue is solved in http://stackoverflow.com/questions/218384/what-is-a-nullpointerexception-and-how-do-i-fix-it – KLCoder Apr 19 '17 at 09:37
  • 1
    That question explains to you **what** an NPE is; and how you solve NPE related problems. NPEs are so common that we do not sit down and debug each time what the exact problem is. Please understand: this is not a free debug service where you are entitled to find somebody that debugs your problem. Sometime we tell you "this is how you fish"; and let you doing the fishing. Even when we would want to help: as others have written, your input doesn't reveal any problem. You would have to rework your question to contain a **full** [mcve]. – GhostCat Apr 19 '17 at 09:48
  • 1
    Revisiting this question after your edit. Yes, you have improved the formatting. But still has the same problems as before. 1) You are not showing us the stacktrace, and 2) you are not showing the code where the exception is actually thrown. So ... given that ... the >>best<< way to solve your problem is for you to read and understand the explanations in the linked Q&A of how to debug NPEs for yourself. – Stephen C Apr 20 '17 at 01:30

0 Answers0