What is Local Variable?

What is Local Variable? Another of the most popular Java developer interview questions. A local variable is a variable that is defined within a method and exists until the method is executed. Once execution ends, the local variable will no longer exist. Here is a program that uses the local variable helloMessage in the main() method:

public static void main(String[] args) {
   String helloMessage;
   helloMessage = "Hello, World!";
   System.out.println(helloMessage);</ span>
}

Rate article
ASJAVA.COM
Add a comment

Your email address will not be published. Required fields are marked *

*

code