Is there more to an interface than having the correct methods

后端 未结 17 976
小鲜肉
小鲜肉 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:35

    The purpose of interfaces is abstraction, or decoupling from implementation.

    If you introduce an abstraction in your program, you don't care about the possible implementations. You are interested in what it can do and not how, and you use an interface to express this in Java.

提交回复
热议问题