Here is a sample code
package org.example; import java.lang.reflect.Method; class TestRef { public void testA(String ... a) { for (String i : a) { System.out.println(i); } } public static void main(String[] args){ Class testRefClass = TestRef.class; for (Method m: testRefClass.getMethods()) { if (m.getName() == "testA") { System.out.println(m); } } } }
Output signal
public void org.example.TestRef.testA(java.lang.String[])
So, the method signature is reported to take an array of String.
Is there any average value in the reflection library, can I say that the method was originally declared to accept varargs?
java variadic-functions
Anthony kong
source share