Java Class New Instance newInstance(Constructor constructor, Object... arguments)

Here you can find the source of newInstance(Constructor constructor, Object... arguments)

Description

Fail-safe.

License

Open Source License

Parameter

Parameter Description
constructor a parameter
arguments a parameter

Return

null on errors.

Declaration

public static Object newInstance(Constructor<?> constructor, Object... arguments) 

Method Source Code


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

import java.lang.reflect.Constructor;

import java.lang.reflect.InvocationTargetException;

public class Main {
    /**/*from w  w  w  . j  a v  a2  s .c  om*/
     * Fail-safe.
     * @param constructor
     * @param arguments
     * @return null on errors.
     */
    public static Object newInstance(Constructor<?> constructor, Object... arguments) {
        try {
            return constructor.newInstance(arguments);
        } catch (InstantiationException e) {
        } catch (IllegalAccessException e) {
        } catch (IllegalArgumentException e) {
        } catch (InvocationTargetException e) {
        }
        return null;
    }
}

Related

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

  10. HOME | Copyright © www.java2s.com 2016