variable
- a name of container on memory address that can store any value inside.
- in Java variable is two type ( instance OR local ) variables.
- instance variable scope inside class other hand local varaible scope inside function.
- instance variable have default value but local not any value
instance variable default value
[ 0 ] integer
[ false ] boolean
[ 0.0 ] floating
[ ' ' ] charactor
Declare variable
datatype vairable_name;
Assign variable
vairable_name = value;
Insalize variable
datatype vairable_name = value;
example
class Test
{
boolean data; // instance variables
public static void main(String args[])
{
// local variables
int n; // declare
n = 0; // assign
int num = 1; // insalize
System.out.println(n+" "+num+" "+data);
}
}
output
0 1 false