V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
qwertyegg
V2EX  ›  Java

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

  •  
  •   qwertyegg · Jul 13, 2019 · 3065 views
    This topic created in 2480 days ago, the information mentioned may be changed or developed.
    3 replies    2019-07-19 13:09:13 +08:00
    bumz
        1
    bumz  
       Jul 13, 2019 via iPhone
    Reflection
    lavvrence
        2
    lavvrence  
       Jul 19, 2019
    同楼上,反射.
    ```
    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
        3
    qwertyegg  
    OP
       Jul 19, 2019
    多谢 @bumz @jaylee4869
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3286 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 13:25 · PVG 21:25 · LAX 06:25 · JFK 09:25
    ♥ Do have faith in what you're doing.