qwertyegg
V2EX  ›  Java

Java 里面有没有类似于 js 的 Function.length 方法,返回参数个数

  •  
  •   qwertyegg · Jul 13, 2019 · 3486 views
    This topic created in 2673 days ago, the information mentioned may be changed or developed.
    3 replies  •  2019-07-19 13:09:13 +08:00
    bumz
    bumz
    Jul 13, 2019 via iPhone
    1
    Reflection
    lavvrence
    lavvrence
    Jul 19, 2019
    2
    同楼上,反射.
    ```
    public static void main(String[] args) throws ClassNotFoundException {
    Class clazz = Class.forName("com.reflection.People");
    Method[] methods = clazz.getDeclaredMethods();
    for (Method method : methods) {
    System.out.println(method.getName());
    Parameter[] parameters = method.getParameters();
    for (Parameter parameter : parameters) {
    System.out.println(parameter.getName());
    }
    }
    }
    ```
    qwertyegg
    qwertyegg
    OP
    Jul 19, 2019
    3
    多谢 @bumz @jaylee4869
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2730 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 10:41 · PVG 18:41 · LAX 02:41 · JFK 05:41
    ♥ Do have faith in what you're doing.