Variable Longentivity is the permission given to not change the value of variable.
final keyword is used to attain variable Longentivity.
Ex-
public class Test
{
public static void main(string args[])
{
final int a=10;
a=20; (Not possible)
System.out.println("the final variable is" +a);
//Value of 'a' will be 10 only.
}
Now the variable can no longer be changed it will stick to value 10.
Comments
Post a Comment