Reputation: 31
I am trying to use JAXB to serialize my java objects to XML. In order to use JAXB the class that has to be serialized must have a no argument constructor. But my problem is all the feilds are final so I cannot do this. If I set the class fields to null like
private final double Offset;
public MyNoArgumentConstructor()
{
this.Offset = null;
}
It would throw a null pointer exception . Any Idea on how I can achieve this?
Upvotes: 0
Views: 207
Reputation: 1621
If you declare as a Double
object instead of double
primitive you won't get an NPE with that code.
Upvotes: 1