Interfaces in Java
An interface is a contract. It says: “Any class that signs this contract promises to provide these methods.” The interface defines what must exist. Each class decides how it works.
interface Greetable { void greet();}class EnglishPerson implements Greetable { @Override public void greet() { System.out.println("Hello!"); }}Using it:
Greetable g = new EnglishPerson();g.greet(); // → "Hello!"