implements CBase{ @Override public void say_sth()

来源:互联网 发布:红外热成像软件 编辑:程序博客网 时间:2024/06/06 03:04
public class hello {/** * @param args */public static void main(String[] args) {// TODO Auto-generated method stubString arg1="world!";System.out.printf("hello %s\n", arg1);CBase obj;obj=new CDerive1();obj.say_sth();obj=new CDerive2();obj.say_sth();}}interface CBase{ void say_sth();}class CDerive1 implements CBase{@Overridepublic void say_sth(){System.out.printf("CDerive1\n");}}class CDerive2  implements CBase{@Overridepublic void say_sth(){System.out.printf("CDerive2\n");}}/*hello world!CDerive1CDerive2*/

原创粉丝点击