An interface in Java is similar to a class, it include only abstract methods and final fields (constants). A class implements an interface by providing code for each method declared by the interface.
Here’s a basic interface that defines a single method, named Playable, that includes a single method named play:
public interface Playable
{
void play();
}
how to use it:
example :
public class TicTacToe implements Playable
{
// additional fields and methods go here
public void play()
{
// code that plays the game goes here
}
// additional fields and methods go here
}