serialisation java code example

Example 1: what is serialization in java

Serialization; when we MAP a Java object to API JSON
format (CONVERT JAVA OBJECT TO JSON);

Deserialization; API JSON/XML ^ MAP it to Java Object
(JSON TO JAVA OBJECT)

Example 2: serializable in JAVA

public class Employee implements java.io.Serializable {
   public String name;
   public String address;
   public transient int SSN;
   public int number;
   
   public void mailCheck() {
      System.out.println("Mailing a check to " + name + " " + address);
   }
}

Example 3: when to use serializable in java

serialize(empObj);

Tags:

Java Example