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:trueorfalsechar: one character
String holds text (it is a class, not a primitive): String name = "Ada";
All lessons in this course
- Variables & Data Types
- Input & Expressions – Part 1
- Input & Expressions – Part 2