+ 2
What is the main difference between a normal class and interface class?
2 ответов
+ 2
An interface is a smart way to do the same thing with several implementations.
You can find interfaces able to work on several systems without the need of knowing the specifies (Unix, Osx, Windows, Android, etc.), e.g. if you need to save or store data, using these interfaces you need only to know the abstract method to use. In this way you simplify the code of your program writing only a single command!
+ 1
Hello,
In java an Interface isn't suppose to have any code inside. You do it with the default function but normally it's here to give a behavior to the others class. Exemple you have:
Interface Animal {
public void feed() {};
}
All the class who implement Animal will need to implement the function feed because an animal need to be feed. It's a behavior. Because not all animals will eat the same things.