Java 接口实例

接口类:

package com.imekaku.jdbc;

/**
 * Created by lee on 17/2/24.
 */
public interface OneInterface {
    String hello(String word);
}

实现类:

package com.imekaku.jdbc;

/**
 * Created by lee on 17/2/24.
 */
public class OneInterfaceImpl implements OneInterface {

    public String hello(String word) {
        return "Word from interface Oneinterface." + "Word";
    }
}

Main:

package com.imekaku.jdbc;

/**
 * Created by lee on 17/2/24.
 */
public class Main {
    public static void main(String[] args) {
        OneInterface oneInterface = new OneInterfaceImpl();
        System.out.println(oneInterface.hello("imekaku"));
    }
}

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

开始在上面输入您的搜索词,然后按回车进行搜索。按ESC取消。

返回顶部