March 2019
Intermediate to advanced
242 pages
6h 21m
English
Java doesn't allow the declaration of variables with the same names in multiple scenarios. For instance, you can't define instance and static variables in a class with the same name. Similarly, you can't define method parameters and local variables with the same names in a method.
However, you can define local variables with the same names as an instance or static variables in a class. This doesn't mean that you can't access them later. To access an instance variable from a method, you can prefix the variable name with the this keyword.
These restrictions allow you to access all of the variables within a scope.
Read now
Unlock full access