Here is the java code for the program Local Variable in Java Example:
public class LocalVariableInJavaExample
{
void show()
{
int LocVar = 10;
System.out.println(LocVar); // local variable.
}
public LocalVariableInJavaExample()
{
int LocVar =15; // local variable within constructor.
System.out.println(LocVar);
}
public static void main(String args[])
{
int LocVar = 5; // another local variable with same name
LocalVariableInJavaExample l = new LocalVariableInJavaExample();
l.show();
System.out.println(LocVar);
}
}
Dinesh Thakur holds an B.C.A, MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular Computer Notes blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.
Related Articles
Basic Courses
Advance Courses