Java Keyword Interface

The reserved keyword interface is used to declare a special type of class that only contains abstract or default methods, constant static fields, and static interfaces. Later on, it can be implemented by classes that declare the interface with the implements keyword.

In the most basic explanation, an interface is a group of related methods with empty bodies.

Let’s take a quick look at a very simple definition of an interface in Java. You can find more detailed information on Java Interfaces and how to properly implement them.

//JavaCodeDepot Sample 

interface Widget {

    void load();

    void unload();


Implementing a Java interface allows a class to become more formal about its behavior it produces. Interfaces form a contract between a class and the outside world. If your class implements an interface, all methods defined by that interface must appear in its source code before the class will successfully compile.

The complete list of Java reserved keywords contains a total of 50 keywords and 3 literal words that are unable to be used as variable names.

Add a Comment

Your email address will not be published. Required fields are marked *