Create new instance by using its contructor
import java.awt.Point;
import java.lang.reflect.Constructor;
public class Main {
public static void main(String[] argv) throws Exception {
Constructor con = Point.class.getConstructor(new Class[] { int.class, int.class });
Point obj = (Point) con.newInstance(new Object[] { new Integer(1), new Integer(1) });
}
}
The output:
public java.lang.String()
public java.lang.String(java.lang.String)
public java.lang.String(char[])
public java.lang.String(char[],int,int)
public java.lang.String(int[],int,int)
public java.lang.String(byte[],int,int,int)
public java.lang.String(byte[],int)
public java.lang.String(java.lang.StringBuilder)
public java.lang.String(byte[],int,int,java.lang.String) throws java.io.UnsupportedEncodingException
public java.lang.String(byte[],int,int,java.nio.charset.Charset)
public java.lang.String(byte[],java.lang.String) throws java.io.UnsupportedEncodingException
public java.lang.String(byte[],java.nio.charset.Charset)
public java.lang.String(byte[],int,int)
public java.lang.String(byte[])
public java.lang.String(java.lang.StringBuffer)
java.lang.String(int,int,char[])
Home
Java Book
Reflection
Java Book
Reflection
Constructor:
- Constructor Reflection
- Print out the contructors declared by String class with Reflection
- Create new instance by using its contructor