DEV Community

Naveen kumar
Naveen kumar

Posted on

Variable in java

Java Variable

  1. Variable is a container it stores data in memory. Each variable has a name, data type and a value.
    **Variable is a name of memory allocation

  2. Variable name should start with small letter.
    *It is Case-sensitive.
    *The type of data that can be stored in a variable is defined by data type.

It is stored in Stack memory.
**Ex
*
int value = 27;
int-> data type
value-> variable name
= -> assignment operator
27 -> data
; -> end of statement

// Declaration and Assignment in different line:
int count; // Declaration
count = 20; // Assignment of a value

//Declared and initialized in one line:
int value = 30;
String class = "Naveen";

Top comments (0)