---
spec: JLS
title: "The Java Language Specification"
edition: "Java SE 16 Edition"
java_version: 16
chapter: "Chapter 15. Expressions"
section: "15.12"
heading: "15.12. Method Invocation Expressions"
parent: "Chapter 15. Expressions"
source: https://docs.oracle.com/javase/specs/jls/se16/html/jls-15.html#jls-15.12
id: "15.12"
url: https://jvm.obfuscated.software/jls/se16/15.12.html
raw: https://jvm.obfuscated.software/jls/se16/15.12.md
---

# 15.12. Method Invocation Expressions

A method invocation expression is used to invoke a class or instance method.

```
MethodInvocation:
  MethodName ( [ArgumentList] )
  TypeName . [TypeArguments] Identifier ( [ArgumentList] )
  ExpressionName . [TypeArguments] Identifier ( [ArgumentList] )
  Primary . [TypeArguments] Identifier ( [ArgumentList] )
  super . [TypeArguments] Identifier ( [ArgumentList] )
  TypeName . super . [TypeArguments] Identifier ( [ArgumentList] )

ArgumentList:
  Expression {, Expression}
```

Resolving a method name at compile time is more complicated than resolving a field name because of the possibility of method overloading. Invoking a method at run time is also more complicated than accessing a field because of the possibility of instance method overriding.

Determining the method that will be invoked by a method invocation expression involves several steps. The following three sections describe the compile-time processing of a method invocation. The determination of the type of the method invocation expression is specified in [§15.12.3](15.12.3.md).

The exception types that a method invocation expression can throw are specified in [§11.2.1](11.2.1.md).

It is a compile-time error if the name to the left of the rightmost "`.`" that occurs before the `(` in a *MethodInvocation* cannot be classified as a *TypeName* or an *ExpressionName* ([§6.5.2](6.5.2.md)).

If *TypeArguments* is present to the left of *Identifier*, then it is a compile-time error if any of the type arguments are wildcards ([§4.5.1](4.5.1.md)).

A method invocation expression is a poly expression if all of the following are true:

- The invocation appears in an assignment context or an invocation context ([§5.2](5.2.md), [§5.3](5.3.md)).
- If the invocation is qualified (that is, any form of *MethodInvocation* except for the first), then the invocation elides *TypeArguments* to the left of the *Identifier*.
- The method to be invoked, as determined by the following subsections, is generic ([§8.4.4](8.4.4.md)) and has a return type that mentions at least one of the method's type parameters.

Otherwise, the method invocation expression is a standalone expression.

**Sections:**

- [15.12.1. Compile-Time Step 1: Determine Type to Search](15.12.1.md)
- [15.12.2. Compile-Time Step 2: Determine Method Signature](15.12.2.md)
- [15.12.3. Compile-Time Step 3: Is the Chosen Method Appropriate?](15.12.3.md)
- [15.12.4. Run-Time Evaluation of Method Invocation](15.12.4.md)
