What is a local variable?
Are you preparing for IT certification? With practice questions, study notes, interactive quizzes, tips and technical articles, uCertify PrepKits ensure that you get a solid grasp of core technical concepts to ace your certification exam in first attempt.
What is a local variable?
Rating:
A local variable is defined inside a block or a method. The lifetime of such a variable is limited by the lifetime of the block in which it is enclosed. It is necessary to initialize a local variable; otherwise, a compile time error will occur. If the same name is used for an instance variable as well as for a local variable, the variable with the local scope will get priority inside the block.
Rating:
Was this information helpful?
Other articles
- What is a static initializer block?
- What is the purpose of the java.awt package?
- Things to practice for Sun test CX310-055.
- What is the toString() method?
- Java 2 Platform Micro Edition (J2ME)