用java编写一个程序用到接口,能用到接口概念的就行

如题所述

Display.java   接口代码如下:

public interface Display {
public void dis();
}

接口的实现类DisplayImpl.java    代码如下:

public class DisplayImpl implements Display {

@Override
public void dis() {
// TODO Auto-generated method stub
System.out.println("输出方法");
}

public static void main(String[] args) {
new DisplayImpl().dis();
}
}

追问

非常感谢!

温馨提示:答案为网友推荐,仅供参考
第1个回答  2015-04-02
interface AInterface {
public String getName();
}

public class Test implements AInterface{

public static void main(String[] args) {
AInterface a=new Test();
System.out.println(a.getName());
}
public String getName() {
return "hello world";
}
}