Literals in Java are the fixed sequence of characters (digit, letters) that are in the form of constant values that are assigned to the variable. Literals can be number, letter or anything which is represented in the form of a constant value.

What are Literals in Java

Literal in Java represents constant value to be stored in variables. Literals are syntactic representations of boolean, character, numeric, or string data.

There are five types of literals:

  1. Integer Literals
  2. Floating-point Literals
  3. Character Literals
  4. String Literals
  5. Boolean Literals

Integer Literals in Java

There are four primitive data types present in integer literals, they are a byte, short, long, int and we can represent these in 4 ways:

#java #java literals

What are Literals in Java | Java Literals Example
1.25 GEEK