Java / Local Variables
Local variable also known as block level variable, are identifiers that are declared within a block of code or method.
This variable need to be initialized before using it.
In the below examples, "i" variable is an example of local variable and it is visible only to the enclosing block.
{ int i; }
void methodName() { int i; }
The local or method level variables are not initialized to any default value, neither primitives nor object references.
Inline value represents the literals in a Java program.
For example, String str = "Hello", here the string "Hello" is a inline value.
The keyword final ensures that the variable is initialized only once and cannot be altered. Reinitializing would issue compilation errors.
Any variable that is initialized only once and not marked as final is known as effectively final. This variable when marked final will not issue any compilation errors.
Yes. From Java 8, local variables are accessible from local class that are final or effectively final. Prior to Java 8, it allowed only final variables.
Synthetic fields are compiler generated fields to hold reference to the inner local class which is required by JVM.
Synthetic fields are scoped private.