Serializable is a marker interface (has no data member and method). It is used to "mark" Java classes so that objects of these classes may get a certain capability. The Cloneable and Remote are also marker interfaces.
It must be implemented by the class whose object you want to persist.
The String class and all the wrapper classes implement the java.io.Serializable interface by default.
Let's see the example given below:
import java.io.Serializable;
public class Student implements Serializable{
int id;
String name;
public Student(int id, String name) {
this.id = id;
this.name = name;
}
}
In the above example, the Student class implements a Serializable interface. Now its objects can be converted into the stream.