Skip to content

Latest commit

 

History

History
15 lines (12 loc) · 606 Bytes

File metadata and controls

15 lines (12 loc) · 606 Bytes

01 — Data types & variables

Overview

  • Primitive types: int, double, boolean, char, long, short, byte, float.
  • Reference types: String, arrays, and objects (instances of classes).
  • Variables hold values; each variable has a type that determines what it can store.
  • Use final for constants.

Common gotchas

  • String is immutable.
  • Numeric literal types: add L for long, f for float.
  • Integer division truncates (e.g., 3/2 == 1). Use 3.0/2 for floating division.

Example: DatatypesExample.java

  • Demonstrates declarations, assignment, constants, and type conversion.