锘??xml version="1.0" encoding="utf-8" standalone="yes"?>成人av二区,蜜桃一区二区三区,久久婷婷蜜乳一本欲蜜臀http://www.aygfsteel.com/morgan/category/52603.htmlzh-cnThu, 13 Sep 2012 16:25:19 GMTThu, 13 Sep 2012 16:25:19 GMT60java鍙嶅皠璋冪敤main鏂規(guī)硶錛宲rivate鏂規(guī)硶瀹炵幇http://www.aygfsteel.com/morgan/articles/reflection.htmlmorganmorganWed, 12 Sep 2012 12:55:00 GMThttp://www.aygfsteel.com/morgan/articles/reflection.htmlhttp://www.aygfsteel.com/morgan/comments/387590.htmlhttp://www.aygfsteel.com/morgan/articles/reflection.html#Feedback0http://www.aygfsteel.com/morgan/comments/commentRss/387590.htmlhttp://www.aygfsteel.com/morgan/services/trackbacks/387590.html   
public class HelloWorld { 
    public static void main(String[] args) {
        System.out.println("HelloWorld");
    }
    private void prt(String msg){
        System.out.println(msg);
    }
}
  
     璋冪敤main鏂規(guī)硶濡備笅錛?br />        
public class HelloWorldRefection { 
    public static void main(String[] args) throws InstantiationException, IllegalAccessException, 
        SecurityException, NoSuchMethodException, IllegalArgumentException, InvocationTargetException {
        Method method = HelloWorld.class.getMethod("main",String[].class);
        method.invoke(null,(Object)new String[]{});
    }
}
     璋冪敤private鏂規(guī)硶濡備笅:
    
 public class HelloWorldRefection { 
    public static void main(String[] args) throws InstantiationException, IllegalAccessException, 
    SecurityException, NoSuchMethodException, IllegalArgumentException, InvocationTargetException {
        Class clazz = HelloWorld.class;
        HelloWorld helloworld = HelloWorld.class.newInstance();
        Method[] methods = clazz.getDeclaredMethods();
        for (Method method : methods) {
            System.out.println(method.getName());
            if(method.getName().equals("prt")){
                method.setAccessible(true);
                method.invoke(helloworld, "hello");
            }
        }
    }
}
     鎬葷粨:
            1 璋冪敤main鏂規(guī)硶闇瑕佹敞鎰忥紝main鏂規(guī)硶鐨勫弬鏁頒負String[]錛屼絾鏄湪method.invoke鏃訛紝闇瑕佸皢String[]寮哄埗杞崲涓篛bject錛岃嚦浜庡師鍥狅紝緗戜笂寰堝璇磋繖涓紝涓?      瑕佹槸璇磈dk鎵цmain鏂規(guī)硶鏃惰灝哠tring[]鍒嗘垚澶氫釜鍙傛暟絳夌瓑銆傚悗緇垜鍒嗘瀽浜嗘簮浠g爜鍚庯紝浼氬皢榪欎釜闂涓撻棬鍐欎釜鏂囩珷鍑烘潵銆?br />            2 璋冪敤private鏂規(guī)硶闇瑕佹敞鎰忥紝鍦ㄨ皟鐢ㄦ鏂規(guī)硶涔嬪墠錛岄渶瑕佸皢姝ゆ墽琛岀殑鏂規(guī)硶璁劇疆浠ヤ笅錛岃屼笉鏄殢渚挎壘涓湴鏂硅繍琛屼笅method.setAccessible(true)灝卞畬浜嬩簡銆?br />            3 浣跨敤鍙嶅皠鍔ㄦ佽皟鐢ㄦ柟娉曟椂錛屼富瑕佹槸鐢╩ethod.invoke()鏂規(guī)硶錛屽鏋滄槸闈欐佹柟娉曪紝鍒檌nvoke鐨勭涓涓弬鏁拌緗畁ull錛屽鏋滀笉鏄潤鎬佹柟娉曪紝鍒欏皢絎竴涓弬鏁拌      緗負璇ョ被鐢熸垚鐨勫璞″嵆鍙?img src ="http://www.aygfsteel.com/morgan/aggbug/387590.html" width = "1" height = "1" />

morgan 2012-09-12 20:55 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 肥城市| 镇原县| 临邑县| 雅江县| 九龙县| 休宁县| 建水县| 翁牛特旗| 江川县| 河西区| 昌都县| 富宁县| 永平县| 綦江县| 科尔| 博乐市| 汉中市| 名山县| 修文县| 县级市| 曲松县| 平原县| 彰化县| 阳春市| 阳谷县| 天气| 卓尼县| 景德镇市| 塔城市| 黎川县| 若羌县| 闸北区| 彝良县| 陵水| 郎溪县| 潍坊市| 武穴市| 龙里县| 秦安县| 永和县| 兴和县|