showmethods.java

来自「《java设计模式》一书的源码」· Java 代码 · 共 26 行

JAVA
26
字号
import java.lang.reflect.*;
import javax.swing.*;
// a simple example program to
//list all the methods of the JList class
//not part of the JTwoLists project

public class showMethods
{
   public showMethods()
   {
      JList list = new JList();
      Method[] methods = list.getClass().getMethods();
      for (int i = 0; i < methods.length; i++)
      {
         System.out.println(methods[i].getName());
         Class cl[] = methods[i].getParameterTypes();
         for(int j=0; j < cl.length; j++)
            System.out.println(cl[j].toString());
      }
   }
   static public void main(String argv[])
   {
      new showMethods();
   }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?