Java Array Type Get arrayComponentClassFromArray(T[] arg)

Here you can find the source of arrayComponentClassFromArray(T[] arg)

Description

Helper method to create an arrayComponentType from the componentType of an array that's provided.

License

Open Source License

Parameter

Parameter Description
arg the array
T parameterizes the array

Return

the component type of the array

Declaration

@SuppressWarnings(value = { "unchecked" })
public static <T> Class<T> arrayComponentClassFromArray(T[] arg) 

Method Source Code

//package com.java2s;
// compliance with the InfoGrid license. The InfoGrid license and important

public class Main {
    /**// w w w  .  j a  va  2 s.c o m
     * Helper method to create an arrayComponentType from the componentType of an array
     * that's provided.
     *
     * @param arg the array
     * @return the component type of the array
     * @param <T> parameterizes the array
     */
    @SuppressWarnings(value = { "unchecked" })
    public static <T> Class<T> arrayComponentClassFromArray(T[] arg) {
        return (Class<T>) arg.getClass().getComponentType();
    }
}

Related

  1. arrayBaseClass(Class c)
  2. arrayClass(Class klass)
  3. arrayClass(Class compClass)
  4. arrayElementIsObjectType(Class clazz)