Guided Notes

Variables, Types & Operators

Primitive and reference types, final constants, var, type casting, and arithmetic, comparison, and logical operators.

Declaring variables

Slide 1 / 5

type name = value;

int count = 5; double price = 19.99; char grade = 'A'; boolean isOpen = true; String city = "Paris";

Declare several at once: int x = 1, y = 2, z = 3;

final makes a constant that can't be changed: final double TAX_RATE = 0.08;

var (Java 10+) lets the compiler infer the type from the value: var total = 42; is still an int.

← Introduction to Java