Open the app

Variables and Data Types

A variable is a named "box" in memory (RAM); its type decides what can go in the box: int (whole number), double (fraction), boolean (true/false), char (one character), String (text). Why: all programming is storing data + transforming it — the variable is its smallest unit. Every userId, lessonTitle, score in Samevian is a variable. When: literally every line of code. How: declaration + assignment: `int age = 25;` -> a cell is allocated in RAM (Phase 0, lesson 1), tagged "age". Where: inside main/methods (local); you'll reach class-level "fields" in Phase 4. Who: you write it, the compiler is the type police — a wrong-type value can't enter the box.

5 min · 10 XP

Start Learning →

What this asks you

Which data type should be used to declare a variable representing storage capacity in a storage technology context?

and 2 more questions

Before this

This opens up

Where our lessons come from →

← Samevia