Commit 4f8f7d1
committed
feat: Demonstrate behavior of static vs non-static variables in method context [StaticVsNonStaticVariable.png]
📌 Focus:
Illustrates how static (`a`) and non-static (`b`) variables behave across multiple method calls in Java using a simple class.
🧠 Logic:
- `static int a = 10`: Shared across all instances, retains its value between method calls.
- `int b = 10`: Local to `fun()` method, re-initialized every time the method is called.
- Method `fun()` increments both variables and prints them to show scope and memory persistence differences.
💡 Key Insight:
- `a` persists and accumulates due to static storage.
- `b` resets with each method call due to local scope.
Signed-off-by: Somesh diwan <[email protected]>1 parent 7f2f399 commit 4f8f7d1
File tree
1 file changed
+0
-0
lines changed- Section10Methods/LocalandGlobalVariables/src
1 file changed
+0
-0
lines changed
0 commit comments