---
spec: JLS
title: "The Java Language Specification"
edition: "Java SE 8 Edition"
java_version: 8
chapter: "Chapter 8. Classes"
section: "8.4.4"
heading: "8.4.4. Generic Methods"
parent: "8.4. Method Declarations"
source: https://docs.oracle.com/javase/specs/jls/se8/html/jls-8.html#jls-8.4.4
id: "8.4.4"
url: https://jvm.obfuscated.software/jls/se8/8.4.4.html
raw: https://jvm.obfuscated.software/jls/se8/8.4.4.md
---

# 8.4.4. Generic Methods

A method is *generic* if it declares one or more type variables ([§4.4](4.4.md)).

These type variables are known as the *type parameters* of the method. The form of the type parameter section of a generic method is identical to the type parameter section of a generic class ([§8.1.2](8.1.2.md)).

A generic method declaration defines a set of methods, one for each possible invocation of the type parameter section by type arguments. Type arguments may not need to be provided explicitly when a generic method is invoked, as they can often be inferred ([§18 (*Type Inference*)](18.md)).

The scope and shadowing of a method's type parameter is specified in [§6.3](6.3.md).

Two methods or constructors `M` and `N` have the *same type parameters* if both of the following are true:

- `M` and `N` have same number of type parameters (possibly zero).
- Where A_1, ..., A_n are the type parameters of `M` and B_1, ..., B_n are the type parameters of `N`, let *θ=[B_1:=A_1, ..., B_n:=A_n]*. Then, for all *i* (1 ≤ *i* ≤ *n*), the bound of A_i is the same type as θ applied to the bound of B_i.

Where two methods or constructors `M` and `N` have the same type parameters, a type mentioned in `N` can be *adapted to the type parameters* of `M` by applying θ, as defined above, to the type.
