In reply to aiswaryanatarajan:
The variable i has an automatic lifetime. It gets allocated when calling the function.
Also see Why is my code not failing when accessing non static method from not static class? | Verification Academy