google Ads

Friday, July 17, 2009

Variable Initialization

Variable Initialization in JAVA

Local variables and member variables can be initialized with an assignment statement when they are declared. The data type of both sides of the assignment statement must match. The countChars method provides and initial value of zero for count when declaring it:

int sum=0;
int a=10;
float salary= 5000;
double sal = 6000;

The value assigned to the variable must match the variable’s type. Method parameters and exception-handler parameters cannot be initialized in the way. The value for a parameter is set by the caller.

No comments:

Post a Comment