Skip to content

Instantly share code, notes, and snippets.

@joa
Created July 30, 2015 10:42
Show Gist options
  • Save joa/b33da09d811e8f269fe9 to your computer and use it in GitHub Desktop.
Save joa/b33da09d811e8f269fe9 to your computer and use it in GitHub Desktop.
import java.lang.reflect.Constructor;
import java.util.Arrays;
import java.util.List;
public final class Foo {
public static void main(String[] args) {
final Constructor<?>[] ctors = A.class.getDeclaredConstructors();
for(Constructor<?> ctor : ctors) {
System.out.println(Arrays.toString(ctor.getParameterTypes()));
System.out.println(Arrays.toString(ctor.getGenericParameterTypes()));
System.out.println();
}
}
private class A {
A(String a) {}
A(List<String> a) {}
}
}
@joa
Copy link
Author

joa commented Jul 30, 2015

[class Foo, class java.lang.String]
[class Foo, class java.lang.String]

[class Foo, interface java.util.List]
[java.util.List<java.lang.String>] //wait, where is Foo?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment