Array.newInstance(Class <?> componentType, int length) has the following syntax.
public static Object newInstance(Class <?> componentType, int length) throws NegativeArraySizeException
In the following code shows how to use Array.newInstance(Class <?> componentType, int length) method.
import java.lang.reflect.Array; public class Main { public static void main(String[] argv) throws Exception { int[] ints = (int[]) Array.newInstance(int.class, 10); String[] stringArray = (String[]) Array.newInstance(String.class, 10); } }