- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLocalVariableExample.java
More file actions
Latest commit
26 lines (20 loc) · 870 Bytes
/
Copy pathLocalVariableExample.java
File metadata and controls
26 lines (20 loc) · 870 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
packagePhase1_CoreLanguage.Variables;
/**A variable defined within a block or method or constructor is called local variable.
* These variable are created when the block in entered or the function is called and destroyed after exiting from the block or when the call returns from the function.
* The scope of these variables exists only within the block in which the variable is declared. i.e. we can access these variable only within that block.
* Initialisation of Local Variable is Mandatory.**/
publicclassLocalVariableExample {
publicvoidStudentAge() {
intage = 20;
System.out.println(age);
age += 20;
System.out.println(age);
}
publicstaticvoidmain(String[] args) {
LocalVariableExampleexample = newLocalVariableExample();
example.StudentAge();
}
//OUTPUT
//20
//40
}