filmov
tv
Learn Java Programming - Introduction to Variable Scope Tutorial

Показать описание
A variable is a named memory location that can be assigned a value while the program is running. Access to variables depends a great deal on where the variable is first created. This tutorial will focus on variables created inside of a method body or as parameters in the method signature. Variable scope will determine what parts of your program have access to certain variables. In many previous tutorials, I have referred to the area inside of an opening and closing curly brace as the code block. Variables created inside of these code blocks cannot be accessed outside of the code block. Control flow statements like the if and for statements, typically have code blocks directly following the closing parenthesis. Nested code blocks are called inner code blocks. The nested code blocks have access to the variables created in the outer code blocks but not vice versa.