Java tutorial
//package com.java2s; /** * Copyright (c) 2015 FeedHenry Ltd, All Rights Reserved. * * Please refer to your contract with FeedHenry for the software license agreement. * If you do not have a contract, you do not have a license to use this software. */ public class Main { private static <T> Class<T> findClass(String className, Class<?>[] declaredClasses) { for (Class<?> klass : declaredClasses) { if (klass.getSimpleName().matches(className)) { return (Class<T>) klass; } } throw new IllegalArgumentException(String.format("Class name %s not found ", className)); } }