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

# Chapter 9. Interfaces

An interface declaration introduces a new reference type whose members are classes, interfaces, constants, and methods. This type has no instance variables, and typically declares one or more `abstract` methods; otherwise unrelated classes can implement the interface by providing implementations for its `abstract` methods. Interfaces may not be directly instantiated.

A *nested interface* is any interface whose declaration occurs within the body of another class or interface.

A *top level interface* is an interface that is not a nested interface.

We distinguish between two kinds of interfaces - normal interfaces and annotation types.

This chapter discusses the common semantics of all interfaces - normal interfaces, both top level ([§7.6](7.6.md)) and nested ([§8.5](8.5.md), [§9.5](9.5.md)), and annotation types ([§9.6](9.6.md)). Details that are specific to particular kinds of interfaces are discussed in the sections dedicated to these constructs.

Programs can use interfaces to make it unnecessary for related classes to share a common `abstract` superclass or to add methods to `Object`.

An interface may be declared to be a *direct extension* of one or more other interfaces, meaning that it inherits all the member types, instance methods, and constants 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, 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.

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 Type Declarations](9.5.md)
- [9.6. Annotation Types](9.6.md)
- [9.7. Annotations](9.7.md)
- [9.8. Functional Interfaces](9.8.md)
- [9.9. Function Types](9.9.md)
