Tutorial by Examples

What is Serialization Serialization is the process of converting an object's state (including its references) to a sequence of bytes, as well as the process of rebuilding those bytes into a live object at some future time. Serialization is used when you want to persist the object. It is also used b...
Serialization with Gson is easy and will output correct JSON. public class Employe { private String firstName; private String lastName; private int age; private BigDecimal salary; private List<String> skills; //getters and setters } (Serialization) ...
Following is an implementation that demonstrates how an object can be serialized into its corresponding JSON string. class Test { private int idx; private String name; public int getIdx() { return idx; } public void setIdx(int idx) { this.idx = idx; ...
In this example we want to create a class that will generate and output to console, a random number between a range of two integers which are passed as arguments during the initialization. public class SimpleRangeRandom implements Runnable { private int min; private int max; pr...
When you implement java.io.Serializable interface to make a class serializable, the compiler looks for a static final field named serialVersionUID of type long. If the class doesn't have this field declared explicitly then the compiler will create one such field and assign it with a value which come...
We consume rest API as a JSON format and then unmarshal it to a POJO. Jackson’s org.codehaus.jackson.map.ObjectMapper “just works” out of the box and we really don’t do anything in most cases. But sometimes we need custom deserializer to fulfill our custom needs and this tutorial will guide you thro...

Page 1 of 1