随笔 - 17,  文章 - 0,  评论 - 0
//实现接口
public
interface MyInterface { void pri(); } public class TestClass1 { public MyInterface test(){ return new MyInterface(){ public void pri() { System.out.println(1); } }; } public static void main(String[] args) { MyInterface my = new TestClass1().test(); my.pri(); } }
//继承类
public abstract class AbstructClass {
    abstract void pri();
}

public class TestClass2 {
    public AbstructClass te(){
        return new AbstructClass(){
            void pri() {
                System.out.println(1);
            }
        };
        
    }
    public static void main(String[] args) {
        AbstructClass abc = new TestClass2().te();
        abc.pri();
    }
}

 

posted on 2013-10-09 15:51  new PersonBean()  阅读(1120)  评论(0编辑  收藏