3.
class checkfinal
{
public static void main(
String[] args)
{
B b = new B();
b.call();
System.out.println("Hello World!");
}
}
class A
{
final int i = 10;
};
class B extends A
{
A a = new A();
//int i = 100;//redeclaration allowed.
void call()
{
//int i = 20;//redeclaration allowed
i = 25;// Can't assign a value to a final variable: i
}
};
//This also works fine.
DOUBT: HERE REDECLARATION ANY NO OF TIMES IS ALLOWED. THEN WHY IS REASSIGNMENT NOT ALLOWED? IS IT THAT FINAL VARIABLES CAN BE REDECLARED ANY NO OF TIMES?
Thanks in advance
Padmini