we cannot reinitialized the final variable.
we initialized it at time of declaration.
if we reinitialized we will get compile time error.
Example 2- final E e1=new E();
e1=null;
give compile time error reinitialize
Example 3- final F f2=new F();
f2=f1;
compile time error
Example 4 final String s="abc";
s="xyz";
compile time error
Example 5- final int []x=new int[2];
x=null;
compile time error
we initialized it at time of declaration.
if we reinitialized we will get compile time error.
Example 2- final E e1=new E();
e1=null;
give compile time error reinitialize
Example 3- final F f2=new F();
f2=f1;
compile time error
Example 4 final String s="abc";
s="xyz";
compile time error
x=null;
compile time error
Example 6-argument of method can also be final.
void test(int a,final int b);
No comments :
Post a Comment