Variables
Learn Variables (Programming Concepts, Programming Fundamentals) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.
What is a Variable? A variable is a named location in memory that holds a value your program can use and change while it runs. Think of it like a labeled box: the label (variable name) never changes, but you can swap out what's inside the box (the value) as your program executes. In Java, every variable must have a type declared before it can be used - this tells the compiler what kind of data (and how much memory) the box can hold.