Java Class New Instance newInstanceWithFill(Class componentType, int length, Object filledValue)

Here you can find the source of newInstanceWithFill(Class componentType, int length, Object filledValue)

Description

new Instance With Fill

License

Open Source License

Declaration

public static Object newInstanceWithFill(Class<?> componentType, int length, Object filledValue) 

Method Source Code


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

import java.lang.reflect.Array;

public class Main {

    public static Object newInstanceWithFill(Class<?> componentType, int length, Object filledValue) {
        Object array = Array.newInstance(componentType, length);
        for (int i = 0; i < Array.getLength(array); i++) {
            Array.set(array, i, filledValue);
        }//  w  w w . j  av a  2s .c  o m
        return array;
    }
}

Related

  1. newInstanceOf(String className)
  2. newInstanceOrThrow(final Class clazz)
  3. newInstancesViaMetaAnnotation(Class declarator, Class metaAnnotationClass, Class expected)
  4. newInstanceViaAnnotation(Class declarator, Annotation annotation, Class expected, Annotation parameter)
  5. newInstanceWithDefaults(Class annotationType)
  6. newInstanceWithoutInit(Class clazz)
  7. newInstanceWithParameterTypes(Constructor constructor)