Quote:
the interface doesn't apear to reduce any code length or making anything easier in the programming
That's either because you don't understand it, or you just aren't experienced enough yet.
An interface isn't a class at all - it just looks like one. What it is is a promise, or a contract: "if you do this thing, I'll let you join my club" And joining the club gives you advantages that all members share, and non members don't.
For example, you use
foreach
in your code, yes? That works because each of the collections you can use with
foreach
implement the
Iterable interface[
^] - it you don't implement it, you can't iterate over it! If your class implements Iterable, it "joins the club" and an instance of your class can be used as a target in a
foreach
. If it doesn't, the compiler "door staff" / "bouncers" won't let it in! :laugh:
That's an obvious example, but there are many, many places where Interfaces make a developers life easier, just as Inheritance itself does. As Richard suggests - read the documentation!