0Pricing
Java Academy · Lesson

Variables & Data Types

Understand variables, primitive data types, declarations, assignment, and basic output.

What Are Variables

Variables store values your program can use and change. Think of a variable as a labeled box.

  • Each variable has a type that defines what it can hold.
  • Names should be short and meaningful (e.g., count, price).
  • Use one variable per distinct piece of information.

Types Overview

Primitive types:

  • int: whole numbers (e.g., 0, 7, -12)
  • double: decimals (e.g., 3.5, -0.25)
  • boolean: true or false
  • char: one character

String holds text (it is a class, not a primitive): String name = "Ada";

All lessons in this course

  1. Variables & Data Types
  2. Input & Expressions – Part 1
  3. Input & Expressions – Part 2
← Back to Java Academy