package scjp;
abstract interface Myinter {
static final int i = 5;
void fun();
}
public class interface2 implements Myinter{
static int i=7;
public void fun(){
System.out.println(i);
}
public static void main(String[] args){
Myinter m = new interface2();
m.fun();
System.out.println(m.i);
}
}
The answer is 7 and 5.
My question is all the variables in an interface is implicitly public,static and final.Then how can we change the valiue of i in class interface2 which implements the interface Myinter.I am confused.please help
Thanks
abstract interface Myinter {
static final int i = 5;
void fun();
}
public class interface2 implements Myinter{
static int i=7;
public void fun(){
System.out.println(i);
}
public static void main(String[] args){
Myinter m = new interface2();
m.fun();
System.out.println(m.i);
}
}
The answer is 7 and 5.
My question is all the variables in an interface is implicitly public,static and final.Then how can we change the valiue of i in class interface2 which implements the interface Myinter.I am confused.please help
Thanks