---
spec: JLS
title: "The Java Language Specification"
edition: "Java SE 18 Edition"
java_version: 18
chapter: "Chapter 9. Interfaces"
section: "9"
heading: "Chapter 9. Interfaces"
source: https://docs.oracle.com/javase/specs/jls/se18/html/jls-9.html
id: "9"
url: https://jvm.obfuscated.software/jls/se18/9.html
raw: https://jvm.obfuscated.software/jls/se18/9.md
---

# Chapter 9. Interfaces

An interface declaration defines a new interface that can be implemented by one or more classes. Programs can use interfaces to provide a common supertype for otherwise unrelated classes, and to make it unnecessary for related classes to share a common `abstract` superclass.

Interfaces have no instance variables, and typically declare one or more `abstract` methods; otherwise unrelated classes can implement an interface by providing implementations for its `abstract` methods. Interfaces may not be directly instantiated.

A *top level interface* ([§7.6](7.6.md)) is an interface declared directly in a compilation unit.

A *nested interface* is any interface whose declaration occurs within the body of another class or interface declaration. A nested interface may be a member interface ([§8.5](8.5.md), [§9.5](9.5.md)) or a local interface ([§14.3](14.3.md)).

An *annotation interface* ([§9.6](9.6.md)) is an interface declared with distinct syntax, intended to be implemented by reflective representations of *annotations* ([§9.7](9.7.md)).

This chapter discusses the common semantics of all interfaces. Details that are specific to particular kinds of interfaces are discussed in the sections dedicated to these constructs.

An interface may be declared to be a *direct extension* of one or more other interfaces, meaning that it inherits all the member classes and interfaces, instance methods, and `static` fields of the interfaces it extends, except for any members that it may override or hide.

A class may be declared to *directly implement* one or more interfaces ([§8.1.5](8.1.5.md)), meaning that any instance of the class implements all the `abstract` methods specified by the interface or interfaces. A class necessarily implements all the interfaces that its direct superclasses and direct superinterfaces do. This (multiple) interface inheritance allows objects to support (multiple) common behaviors without sharing a superclass.

Unlike a class, an interface cannot be declared `final`. However, an interface may be declared `sealed` ([§9.1.1.4](9.1.1.4.md)) to limit its subclasses and subinterfaces.

A variable whose declared type is an interface type may have as its value a reference to any instance of a class which implements the specified interface. It is not sufficient that the class happen to implement all the `abstract` methods of the interface; the class or one of its superclasses must actually be declared to implement the interface, or else the class is not considered to implement the interface.

**Sections:**

- [9.1. Interface Declarations](9.1.md)
- [9.2. Interface Members](9.2.md)
- [9.3. Field (Constant) Declarations](9.3.md)
- [9.4. Method Declarations](9.4.md)
- [9.5. Member Class and Interface Declarations](9.5.md)
- [9.6. Annotation Interfaces](9.6.md)
- [9.7. Annotations](9.7.md)
- [9.8. Functional Interfaces](9.8.md)
- [9.9. Function Types](9.9.md)
