---
spec: JLS
title: "The Java Language Specification"
edition: "Java SE 11 Edition"
java_version: 11
chapter: "Chapter 3. Lexical Structure"
section: "3.5"
heading: "3.5. Input Elements and Tokens"
parent: "Chapter 3. Lexical Structure"
source: https://docs.oracle.com/javase/specs/jls/se11/html/jls-3.html#jls-3.5
id: "3.5"
url: https://jvm.obfuscated.software/jls/se11/3.5.html
raw: https://jvm.obfuscated.software/jls/se11/3.5.md
---

# 3.5. Input Elements and Tokens

The input characters and line terminators that result from escape processing ([§3.3](3.3.md)) and then input line recognition ([§3.4](3.4.md)) are reduced to a sequence of *input elements*.

```
Input:
  {InputElement} [Sub]

InputElement:
  WhiteSpace
  Comment
  Token

Token:
  Identifier
  Keyword
  Literal
  Separator
  Operator

Sub:
  the ASCII SUB character, also known as "control-Z"
```

Those input elements that are not white space or comments are *tokens*. The tokens are the terminal symbols of the syntactic grammar ([§2.3](2.3.md)).

White space ([§3.6](3.6.md)) and comments ([§3.7](3.7.md)) can serve to separate tokens that, if adjacent, might be tokenized in another manner. For example, the ASCII characters `-` and `=` in the input can form the operator token `-=` ([§3.12](3.12.md)) only if there is no intervening white space or comment.

As a special concession for compatibility with certain operating systems, the ASCII SUB character (`\u001a`, or control-Z) is ignored if it is the last character in the escaped input stream.

Consider two tokens `x` and `y` in the resulting input stream. If `x` precedes `y`, then we say that `x` is *to the left of* `y` and that `y` is *to the right of* `x`.

For example, in this simple piece of code:

```
class Empty {
}
```

we say that the `}` token is to the right of the `{` token, even though it appears, in this two-dimensional representation, downward and to the left of the `{` token. This convention about the use of the words left and right allows us to speak, for example, of the right-hand operand of a binary operator or of the left-hand side of an assignment.
