Return type value if RunTimeException has been thrown and not catched.
- by Alfred
I am using Gson to parse Json. What I don't understand what the return type will be if you don't catch the Runtime Exception. I was expecting it to be null, but it is not null when evaluating with a simple if statement.
My code looks something like this:
public X x() {
return gson.fromJson(jsonString, X.class);
}
then from another function I call the function:
public void y() {
final X x = x();
if (x == null) {
System.out.println("x == null")
}
}
I was expecting x to be null, but it isn't because the print statement is not called? What is the value of x? How can if them. I have my problem by using a catch block in the x() function and returning null. But I am just wondering what the value of function x() is(if any?)? Hopefully I make any sense at all.