- Java Variable is a container that stores data in memory. Every varaiable has a name, data type and a value.
- It is stored in Stack memory.
- Variable name should start with small letter.
- variable name can start with these special characters $ and _
- It is Case-sensitive.
- The type of data that can be stored in a variable is defined by data type.
Ex :
int number = 10;
int -> data type
number -> variable name
= -> assignment operator
10 -> value
; -> end of statement
// Declaration and Assignment in different line:
int speed; // Declaration
speed = 50; // Assignment of a value
//Declared and initialized in one line:
int speed = 50;
String name = "Java";
Top comments (1)
Variable names should start with a lowercase letter — is this mandatory?, what happens when we use capital letter, is it valid?