Search⌘ K

Variables in Java

Understand what variables are in Java and the importance of descriptive identifiers. Learn the rules for naming variables, how data types define memory size, and why variables are essential for storing data during program execution.

Introduction

Variables are just like containers which hold the values while the program is executed.

A variable is a storage location paired with an associated symbolic name (an identifier), which contains some known or unknown quantity of information referred to as a value.

Variables in Java are strongly typed; thus they all must have a data type declared with their identifier. In this lesson, we will discuss identifiers.

Naming a variable

Just as every person has a name that helps identify them, every variable has a name associated with it. There are certain naming conventions that one must follow in order to decide a name for the ...