---
spec: JLS
title: "The Java Language Specification"
edition: "Java SE 13 Edition"
java_version: 13
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/se13/html/jls-3.html#jls-3.9
id: "3.9"
url: https://jvm.obfuscated.software/jls/se13/3.9.html
raw: https://jvm.obfuscated.software/jls/se13/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.

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.7](3.10.7.md)).
- `var` is not a keyword, but rather an identifier with special meaning as the type of a local variable declaration ([§14.4](14.4.md), [§14.14.1](14.14.1.md), [§14.14.2](14.14.2.md), [§14.20.3](14.20.3.md)) and the type of a lambda formal parameter ([§15.27.1](15.27.1.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.
