They are implicitly static and final because instance variables don't work with polymorphism. They can be used to allow implementing classes to have access to the same set of constants.
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
interface i1{
int a=12;
}
interface i2{
int a=21;
}
class exampleInterface implements i1,i2{
public static void main(String...a){
System.out.println(a);// it is compilation error
}
}
Arun Giridharan wrote:Interface came into picture to solve the problem of Diamond shape problem.If you know what is static and final keywords that's you have the answer.
Interface where introduced to allow programming to an interface and not an implementation. This allows you to decouple the implementation and the interface.
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.