L020 | Literals in Java | Class 9th | ICSE | Computer Applications | Java

What are Literals?

For example:

int age = 25; // Here, 25 is a literal.

Why Are Literals Important?

Types of Literals in Java

Java provides several types of literals to represent different kinds of data. Below are the main types of literals, discussed as per the ICSE syllabus.

1. Integer Literals

Types of Integer Literals:

  1. Decimal (Base 10): Numbers in the standard numeric system.
  2. Octal (Base 8): Numbers starting with 0.
  3. Hexadecimal (Base 16): Numbers starting with 0x or 0X.
  4. Binary (Base 2): Numbers starting with 0b or 0B.

2. Floating-Point Literals