Variables in Java

You must declare the variables before they can be used.

Declaration:

data type variable_name, variable_name1;

Ex: int a,b,c;

There are three kinds of variables in java:

Local variables: 
Local variables are declared inside the methods, blocks. These are created when method, blocks starts and destroyed when it exits the method, blocks.
Access modifiers are not be used for local variables. These are visible with in that declared method, constructor or block.
Local variables declared in stack level internally
There is no default values for local variables. So, Local must be initialized before its first use.



 

No comments:

Post a Comment