Mehdi
Mehdi

Reputation: 107

Serialisation interface

Is this possible in Java ?

public interface Document implements Serializable{ // a lot of method }

Upvotes: 0

Views: 108

Answers (4)

user4060017
user4060017

Reputation:

Serializable is a class so you can only extend it not implement it.

public interface Document implements Serializable{ // a lot of method }

Upvotes: 1

Paaske
Paaske

Reputation: 4403

No, you have to use extends:

import java.io.Serializable;

public interface Document extends Serializable {     
 // a lot of methods
}

Upvotes: 1

Joe23
Joe23

Reputation: 5782

Interfaces extend other interfaces and do not implement them.

So your code should read:

public interface Document extends Serializable { // a lot of method }

Upvotes: 0

Christian Strempfer
Christian Strempfer

Reputation: 7383

No, you have to extend it. "implements" is only allowed for classes, which implement an interface.

public interface Document extends Serializable { // a lot of method }

Upvotes: 1

Related Questions