Hi. Altough there are many threads about this topic "exception being thrown by JVM / Programmatically" (
and I already read all of these), but still I can't see the difference and I will try to be more clear than the other posts by showing an example of this (confusing) point.
Questions number 5 from chapter 6 says: Which of the following exceptions are thrown by the JVM? And among the options there are two: NullPointerException (the right answer is thown by jvm) and NumberFormatException (right answer, thrown by the programmer). And my question is why.
NullPointerException and NumberFormatException are unchecked and if I do this:
String cad = null;
cad.trim() // NullPointerException (thrown by jvm)
Integer.parseInt("abc"); // NumberFormatException (thrown by the programmer)
So my question is why if both are unchecked exceptions, in the second example we say that NumberFormatException is thrown by the programmer.
What does it do NumberFormatException to be thrown by the programmer if I didn't anything different than in case of NullPointerException?. Can someone tell me please which is the difference that I can't see? .