In all the new applications I've built from scratch, I've never seen the need for an interface, I've read up in the past in text and subsequently ignored and forgotten the real need.
That said, here is a question I've seen asked in the past, which I'll use to ask this particular question by example...
Lets say I have this interface:
public interface IBox
{
public void setSize(int size);
public int getSize();
public int getArea();
//...and so on
}
And I have a class that implements it:
public class Rectangle implements IBox
{
private int size;
//Methods here
}
Used as follows:
public static void main(String args[])
{
Rectangle myBox=new Rectangle();
// do stuff.
System.out.println( myBox.getSize() );
}
Given that I still have to write the setSize getSize getArea methods in the Rectangle class. Given that Rectangle with these methods, would still work even without the IBox interface.
What is the point of having the Ibox interface other than to publicize or dictate or describe the setSize getSize getArea methods?