java.lang.reflect.Constructor
java.lang.Object
None
java.lang.reflect.Member
New as of JDK 1.1
The Constructor class represents a constructor of a class. A Constructor object can be obtained by calling the getConstructor() method of a Class object. Constructor provides methods for getting the name, modifiers, parameters, exceptions, and declaring class of a constructor. The newInstance() method can create a new instance of the class that declares a constructor.
public final class java.lang.reflect.Constructor extends java.lang.Object implements java.lang.reflect.Member { // Instance Methods public boolean equals(Object obj); public Class getDeclaringClass(); public Class[] getExceptionTypes(); public native int getModifiers(); public String getName(); public Class[] getParameterTypes(); public int hashCode(); public native Object newInstance(Object[] initargs); public String toString(); }
The object to be compared with this object.
true if the objects are equal; false if they are not.
Object.equals()
This method returns true if obj is an instance of Constructor, and it is equivalent to this Constructor.
The Class object that represents the class that declared this constructor.
Member.getDeclaringClass()
This method returns the Class object for the class in which this constructor is declared.
An array that contains the Class objects that describe the exceptions that can be thrown by this constructor.
This method returns an array of Class objects that represents the throws clause of this constructor. If the constructor does not throw any exceptions, an array of length 0 is returned. As of Java 1.1.2, this method is not properly supported: it always returns an empty array.
An integer that represents the modifier keywords used to declare this constructor.
Member.getModifiers()
This method returns an integer value that represents the modifiers of this constructor. The Modifier class should decode the returned value.
The name of this constructor as a String.
Member.getName()
This method returns the name of this constructor, which is always the same as the name of the declaring class.
An array that contains the Class objects that describe the parameter types that this constructor accepts.
This method returns an array of Class objects that represents the parameter types this constructor accepts. The parameter types are listed in the order in which they are declared. If the constructor does not take any parameters, an array of length 0 is returned.
A hashcode for this object.
Object.hashCode()
This method returns a hashcode for this Constructor.
public native Object newInstance(Object[] initargs) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException
An array of arguments to be passed to this constructor.
The newly created object.
If the declaring class of this constructor is abstract.
If the constructor is inaccessible.
If initargs is the wrong length or contains any value of the wrong type.
If the constructor itself throws an exception.
This method executes the constructor represented by this object using the given array of arguments. Thus, it creates and initializes a new instance of the declaring class of the constructor. If a particular parameter is of a primitive type, the corresponding argument is automatically unwrapped and converted to the appropriate type, if possible. If that is not possible, an IllegalArgumentException is thrown. If the constructor itself throws an exception, the exception is placed in an InvocationTargetException, which is then thrown to the caller of newInstance(). If the constructor completes normally, the newly created instance is returned.
A string representation of this object.
Object.toString()
This method returns a string representation of this Constructor. This string contains the access modifiers of the constructor, if any, followed by the fully qualified name of the declaring class and a list of the parameters of the constructor, if any. The list is enclosed by parentheses, and the individual parameters are separated by commas. If the constructor does not have any parameters, just the parentheses are included in the string.
Method |
Inherited From |
Method |
Inherited From |
---|---|---|---|
clone() |
Object |
finalize() |
Object |
getClass() |
Object |
notify() |
Object |
notifyAll() |
Object |
wait() |
Object |
wait(long) |
Object |
wait(long, int) |
Object |
Class, Field, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, Member, Method, Modifier, Object