Is there more to an interface than having the correct methods

后端 未结 17 905
小鲜肉
小鲜肉 2020-11-22 13:37

So lets say I have this interface:

public interface IBox
{
   public void setSize(int size);
   public int getSize();
   public int getArea();
  //...and so          


        
17条回答
  •  悲&欢浪女
    2020-11-22 14:34

    you could do

    Ibox myBox = new Rectangle();
    

    that way you are using this object as Ibox and you don't care that its really Rectangle .

提交回复
热议问题