by default interface variables are public static final then what if the implementing class defines the same variable.
example here
Sudheer SCWCD, SCJP 5
Manish Singh
Ranch Hand
Joined: Jan 26, 2007
Posts: 160
posted
0
the two "i" in the interface and class are different so there wont be any problem.
The variables in the interfaces are implicitly "public static and final" .
Anant Jagania
Ranch Hand
Joined: Oct 20, 2004
Posts: 49
posted
0
int i = 20; // why doesnt not it give error,as it is over riding the interface variable.
You cannot override interface/class variable in subclass or implementing class.
Only methods can be overridden.
Hence, variable "i" is different in interface and class.
In your example variable "i" for Interface is static final variable which is accessible globally while variable "i" in Abstract class is accessible only by the class.
how they both i's are different. interface final variables are inherited to implementing class.
in the implementing class how you can assign a new value.