What are local static variables? and How to use them?
1 Answer
0
“Static Variable”
class Test
static int x=100;
class Main
public static void main( String args[ ])
Static variables are those variable which is created with the help of static keyword in a class and it is also called class variable. It creates a single copy in the RAM and each object can share it.
Static variable directly accesses by the help of class name without using any objects.
How to Use it
Syntax :
ClassName. VariableName;
For Example
{
Test( )
{
System. out. println( “Test Class Call...”);
}
}
{
{
Test obj =new Test( );
System. out. println ( “Value of Static Variable : “+ Test. x);
}
}