Variable Scope. Who can see it and what is its lifetime. Definitions. Scope – the portion of the code that knows the variable exists and can see/modify its value Lifetime – when the variable is created and destroyed B lock – a section of code surrounded by curly brackets. Types of Scope.
Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.
Who can see it and what is its lifetime
private void silly()
booleanfinished = false;
System.out.println("Nox here ");
intx = 0;
System.out.println(" x has been created");
while (x < 3)
System.out.println("x is still visible here "+ x);
finished = true;
System.out.println("we can still see x here " + x);
System.out.println("Nowx is gone");