Commit 7f2f399
committed
feat: Distinguish between Local, Instance, and Static Variables with Examples and Comparison Table [var-scope-vip]
📌 Key Focus:
Provides a comprehensive explanation of local, global (instance), and static variables in Java with real-world examples, scope clarification, and a full comparison table.
🧠 Core Concepts:
- **Local Variable**: Declared within a method or block, short-lived, and not accessible outside.
- **Instance Variable (Global)**: Declared inside the class but outside methods, persists as long as the object exists.
- **Static Variable**: Declared with `static`, belongs to the class and shared among all objects, exists for the program lifetime.
📊 Includes:
- Scope, lifetime, and access control for each variable type
- Behavior of default values and initialization
- Real Java code demonstrating each type in action
- Output simulation and side-by-side table for easy comparison
💡 Educational Utility:
Perfect for learners or interview prep – emphasizes **when** and **why** to use each variable type in class design or memory management.
🗂️ Commit Key: [var-scope-vip]
Signed-off-by: Somesh diwan <[email protected]>1 parent ead6ae8 commit 7f2f399
File tree
1 file changed
+2
-2
lines changed- Section10Methods/LocalandGlobalVariables/src
1 file changed
+2
-2
lines changedLines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
129 | | - | |
| 129 | + | |
0 commit comments