What are the literals?

A literal is a sequence of characters that represents a value of a primitive type or a string.
  • Integer. Possible formats: 2019, 1__000_000 (with underscores for readability from Java 7 onwards), 10048L (l is also allowed but can be confused with 1), 0xfd12aa (hexadecimal), 0b1011101 (binary), 07654321 (octal).
  • Floating-point. Possible formats: 123.4, 56.7e8, .07, 42F, 1.4D (redundant as it defaults to double).
  • Characters and strings. A character (char) is enclosed in single quotes: 'R'. Special characters are prefixed with a backslash: '\n'. Any character can be represented by an escape sequence: '\u00F1'. A string literal is a sequence of characters in double quotes: "FooBar". The rules for characters in a string are the same.
  • Boolean. true and false.
  • The special literal null.
All nuances are detailed in the official documentation.