Posts

Showing posts with the label local variable

variables in java with source code example

Java has different set of variables. Which will represent the value is called as variable in java. Based on the type of value represented by a variable, that variable is divided into 2 types. 1.      Primitive Variable 2.      Reference Variable Primitive Variable:  Can be used to represent primitive values. Ex: int x = 10; Reference Variable:  Can be used to refer objects. Ex: Employee emp = new Employee(); Based on the purpose and position of declaring the variables are divided into 3 types. 1.      Instance Variable 2.      Static Variable 3.      Local Variable 1. Instance Variable: If the value of the variable is varied from object to object such type of variables are called instance variable. For every object a separate copy of instance variable will be created. The scope of instance variable is exactly same as the scope of...