瑞得

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

一、创建Myinterface接口

public interface Myinterface
{
    static final String MyifName="我的接口";
    static final String MyifPrice="价格";
    public double getprice();
}

二、创建引用接口的类

public class UseMyinterface
{
    public static void main(String[] args)
    {
        MyServer s = new MyServer();
        System.out.println(s.MyifName+s.MyifPrice);
        System.out.println(s.getprice());
    }
}
class MyServer implements Myinterface
{
    public double getprice()
    {
         return 666.66;
    }
}

三、对于接口的理解
     1、接口就是一个抽象的类,里面定义了一些常量和一些声明但未实现的方法。

posted on 2016-03-09 14:39  瑞得  阅读(269)  评论(0编辑  收藏  举报