Code example for Constructor

Methods: isAccessiblesetAccessiblenewInstance

0
    } 
 
    public Object newInstance() {
        try { 
            Constructor<?> defaultConstructor = getClazz().getDeclaredConstructor(new Class[]{});
            if (!defaultConstructor.isAccessible()) {
                defaultConstructor.setAccessible(true);
            } 
            return defaultConstructor.newInstance(new Object[]{});
        } 
        catch (Exception e) {
            Throwable targetException = null;
            if (e instanceof InvocationTargetException) {
                targetException = ((InvocationTargetException)e).getTargetException();
            } 
            else { 
                targetException = e;
            } 
            throw new NewInstanceCreationException("Could not create a new instance of class [" + 
                    getClazz().getName() + "]!", targetException);
Connect your IDE to all the code out there  Get Codota for Java