Here you can find the source of loadClass(final String className)
Parameter | Description |
---|---|
className | the name of the class to create. |
Parameter | Description |
---|---|
IllegalArgumentException | if the className does not exist. |
@SuppressWarnings("unchecked") public static <T> Class<T> loadClass(final String className) throws IllegalArgumentException
//package com.java2s; //License from project: Open Source License public class Main { /**/* w w w. j a v a 2s . c om*/ * Attempts to create a class from a String. * @param className the name of the class to create. * @return the class. CANNOT be NULL. * @throws IllegalArgumentException if the className does not exist. */ @SuppressWarnings("unchecked") public static <T> Class<T> loadClass(final String className) throws IllegalArgumentException { try { return (Class<T>) Class.forName(className); } catch (final ClassNotFoundException e) { throw new IllegalArgumentException(className + " class not found."); } } }