java反射机制一个例子

import java.lang.reflect.*; 
public class DumpMethods { 
  public static void main(String args[]) { 
   try { 
      Class c = Class.forName("java.util.Stack"); 
      Method m[] = c.getDeclaredMethods(); 
       
      for (int i = 0; i < m.length; i++) 
        System.out.println(m[i].toString()); 
   } 
   catch (Throwable e){ 
      System.err.println(e); 
   } 
  } 
}

参考 http://www.jb51.net/article/55392.htm

posted @ 2016-05-03 21:03  艳鬼  阅读(162)  评论(0编辑  收藏  举报