Java Class New Instance newInstance(Class classZ)

Here you can find the source of newInstance(Class classZ)

Description

new Instance

License

Apache License

Declaration

public static Object newInstance(Class<?> classZ) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.lang.invoke.MethodHandles;

public class Main {
    private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());

    public static Object newInstance(Class<?> classZ) {
        Object instance;/*from w w w . java2  s .co  m*/
        try {
            instance = classZ.newInstance();
        } catch (InstantiationException | IllegalAccessException e) {
            logger.error("new instance failure", e);
            throw new RuntimeException(e);
        }
        return instance;
    }
}

Related

  1. newInstance(Class klass)
  2. newInstance(Class targetClass)
  3. newInstance(Class cl, Object[] args)
  4. newInstance(Class clazz)
  5. newInstance(Class componentType, int length)
  6. newInstance(Class clazz)
  7. newInstance(Class clazz)
  8. newInstance(Class clazz)
  9. newInstance(Class clazz)