Commit 80f94e2
committed
feat: Demonstrate behavior of static and non-static variables across method calls
🧠 Logic:
- `static int a = 10;` is shared across all instances of the class.
- `int b = 10;` is re-initialized every time `fun()` is called.
- On each call to `fun()`:
- `a` retains and increments its value.
- `b` resets to 10, increments to 11, but the new value doesn't persist.
Signed-off-by: Somesh diwan <[email protected]>1 parent 2b8ca1b commit 80f94e2
File tree
1 file changed
+4
-5
lines changed- Section10Methods/LocalandGlobalVariables/src
1 file changed
+4
-5
lines changedLines changed: 4 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
| 3 | + | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
10 | | - | |
| 9 | + | |
11 | 10 | | |
12 | 11 | | |
13 | 12 | | |
14 | 13 | | |
15 | | - | |
| 14 | + | |
0 commit comments