Java Class New Instance newInstance(final Class arrayClass, final int length)

Here you can find the source of newInstance(final Class arrayClass, final int length)

Description

new Instance

License

Open Source License

Declaration

@SuppressWarnings("unchecked")
    public static <T> T newInstance(final Class<T> arrayClass, final int length) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.lang.reflect.Array;

public class Main {
    @SuppressWarnings("unchecked")
    public static <T> T newInstance(final Class<T> arrayClass, final int length) {
        if (!arrayClass.isArray()) {
            throw new IllegalArgumentException("not an array");
        }/*from   w w  w .  j ava  2  s. c o  m*/
        return (T) Array.newInstance(arrayClass.getComponentType(), length);
    }
}

Related

  1. newInstance(Constructor constructor, Object... arguments)
  2. newInstance(Constructor ctor, Object... params)
  3. newInstance(Field field)
  4. newInstance(final Class clazz)
  5. newInstance(final Class clazz, final Object[] parameters)
  6. newInstance(final Class clazz)
  7. newInstance(final Class clazz)
  8. newInstance(final Class clazz)
  9. newInstance(final Class clazz)