Variables in Java

A variable is a container or memory location used to store a value (literal) that can be used later in the program. Variables are essential for holding data temporarily or permanently during program execution.


Classification Based on Scope (Declaration)

image.png

Variables in Java are classified based on where they are declared, which determines their scope and lifetime.

Global Variables

Static Variables

Non-Static Variables