java 反射

 

package com;

public interface IPeople {
public abstract void desc();
}

 

package com;

public class Women implements IPeople {

@Override
public void desc() {
System.out.print("i am a women,and i am 温柔!");
}

}

 

Class<?> demo =Class.forName("com.Women");
IPeople per=(IPeople)demo.newInstance();
per.desc();

posted @ 2015-09-08 15:11  乐上  阅读(110)  评论(0编辑  收藏  举报