Getting the Pair class constructors

The public constructors of a class can be obtained via the Class.getConstructors() class. The returned result is Constructor<?>[]:

Constructor<?>[] constructors = clazz.getConstructors();

// public modern.challenge.Pair(java.lang.Object,java.lang.Object)
System.out.println("Constructors: " + Arrays.toString(constructors));
For fetching all the declared constructors (for example, private and protected constructors), call getDeclaredConstructors(). When searching for a certain constructor, call getConstructor​(Class<?>... parameterTypes) or getDeclaredConstructor​(Class<?>... parameterTypes).
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset