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

# 3.9. Keywords

51 character sequences, formed from ASCII letters, are reserved for use as keywords and cannot be used as identifiers ([§3.8](3.8.md)).

```
Keyword:
  (one of)
  abstract continue for new switch assert default if package synchronized boolean do goto private this break double implements protected throw byte else import public throws case enum instanceof return transient catch extends int short try char final interface static void class finally long strictfp volatile const float native super while _ (underscore)
```

The keywords `const` and `goto` are reserved, even though they are not currently used. This may allow a Java compiler to produce better error messages if these C++ keywords incorrectly appear in programs. The keyword `_` (underscore) is reserved for possible future use in parameter declarations.

A variety of character sequences are sometimes assumed, incorrectly, to be keywords:

- `true` and `false` are not keywords, but rather boolean literals ([§3.10.3](3.10.3.md)).
- `null` is not a keyword, but rather the null literal ([§3.10.8](3.10.8.md)).
- `var`, `yield`, and `record` are not keywords, but rather restricted identifiers ([§3.8](3.8.md)). `var` has special meaning as the type of a local variable declaration ([§14.4](14.4.md)) and the type of a lambda formal parameter ([§15.27.1](15.27.1.md)). `yield` has special meaning in a `yield` statement ([§14.21](14.21.md)); all invocations of a method named `yield` must be qualified so as to be distinguished from a `yield` statement. `record` has special meaning in a record declaration ([§8.10](8.10.md)).

A further ten character sequences are *restricted keywords*: `open`, `module`, `requires`, `transitive`, `exports`, `opens`, `to`, `uses`, `provides`, and `with`. These character sequences are tokenized as keywords solely where they appear as terminals in the *ModuleDeclaration*, *ModuleDirective*, and *RequiresModifier* productions ([§7.7](7.7.md)). They are tokenized as identifiers everywhere else, for compatibility with programs written before the introduction of restricted keywords. There is one exception: immediately to the right of the character sequence `requires` in the *ModuleDirective* production, the character sequence `transitive` is tokenized as a keyword unless it is followed by a separator, in which case it is tokenized as an identifier.
