Java Variable

What is a Variable?

A variable in Java is a symbolic name for a memory location. It provides a way to store data that can be used and manipulated throughout a program. Each variable in Java must have a data type that determines what kind of data it can store.

Variable Declaration and Initialization

Declaration Syntax:

<data_type> <variable_name>;

Initialization Syntax:

<data_type> <variable_name> = <value>;


Example:

int age; // Declaration 
age = 30; // Initialization 
int score = 100; // Declaration and initialization

Post a Comment

0 Comments