I have been wondering the real use of interface. please check the below code.
interface Animal {
public void eat();
public void travel();
}
public class MammalInt implements Animal{
public void eat(){
System.out.println("Mammal eats");
}
public void travel(){
System.out.println("Mammal travels");
}
public int noOfLegs(){
return 0;
}
public static void main(String args[]){
MammalInt m = new MammalInt();
m.eat();
m.travel();
}
}
in the above code if i remove implements Animal from class declaration still the code works fine without any difference. So what is the actual use of interface. ?