why does System.out.println(e.getCause());
gives null
?
And can store whole HashSet collection like this?
private void saving() thro
When an exception is chained, the getCause
method is used to get the original cause. In this case, the exception was not chained from any other layer, hence getCause
returns null
. You should use e.printStackTrace()
instead, to get the reason for the exception. Most likely, this would be because one or more keys/values in your HashSet
are of a type that is not implementing java.io.Serializable
.