1.2 Data Types and Literals
Introduction
Java is statically typed: every value has a type known at compile time. Types split into two families — the eight built-in primitive types (holding raw numeric, character, or boolean values directly) and reference types (objects, arrays, and strings, which hold a reference to data stored elsewhere). A literal is the fixed value you write directly in source code, like `42`, `3.14`, `'A'`, or `true`.
Key Concepts
Java Syntax
Code Examples
Each variable is declared with an explicit primitive type. Underscores in numeric literals (`8_000_000`) are purely for readability and are ignored by the compiler.