Could anyone tell me whats use of implements interface which extended with "Serializable" interface with example?

80 views Asked by At

Interface with serializable implements?

 public interface SearchCriteria extends Serializable {}

class which implements a interface which doesnt have method initilization just a extented by "Serializable" interface

  public class AbstractSearchCriteria implements SearchCriteria
 {
private static final long serialVersionUID = 1L;

private PageCriteria pageCriteria;

public AbstractSearchCriteria()
{
    super();
}

public PageCriteria getPageCriteria()
{
    return pageCriteria;
}

public void setPageCriteria(PageCriteria pageCriteria)
{
    this.pageCriteria = pageCriteria;
}}
2

There are 2 answers

0
KDP On

serialization is the process of translating data structures or object state into a format that can be stored.

Serializable is a marker interface serializable is a special interface that specifies that class is serialiazable. It's special in that unlike a normal interface it does not define any methods that must be implemented: it is simply marking the class as serializable.

more here What is object serialization?

0
ajitksharma On

In short:

You extended Serializable interface in SearchCriteria interface. All classes that implement the SearchCriteria interface, will also be implementing Serializable interface by default.

For more detailed info check the documentation.