A variable is a named storage spot used to hold data. Java is a statically typed language, so you have to declare a variable's data type before you use it. Think of it as Java asking you upfront, "what type are we putting in this box?"
java
public class Main {
public static void main(String[] args) {
String name = "Aung";
int age = 30;
double height = 5.8;
boolean isStudent = false;
System.out.println("Name: " + name);
System.out.println("Age: " + age);
System.out.println("Height: " + height);
System.out.println("Student: " + isStudent);
}
}String stores text. int stores whole numbers, double stores decimal numbers, and boolean stores true/false values. The + operator, when used with a String, joins pieces of text together.
You should see
Name: Aung Age: 30 Height: 5.8 Student: falseReal-world use
All app data—user profiles, product prices, login status, scores, inventory counts—starts out being managed with this same variable concept.