Interfaces

suggest change

Introduction

An interface is a reference type, similar to a class, and is declared with the interface keyword.

Interfaces can contain constants, method signatures, default methods, static methods, and nested types. Method bodies exist only for default methods and static methods. Java 9 also allows private methods. Like abstract classes, interfaces cannot be instantiated. They can only be implemented by classes or extended by other interfaces.

An interface can describe a type without instance fields. Default methods mean it is not only a list of abstract methods.

Syntax

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents